com.codenvy.dev.shell.view.ShellPromptProvider.java Source code

Java tutorial

Introduction

Here is the source code for com.codenvy.dev.shell.view.ShellPromptProvider.java

Source

/*******************************************************************************
 * Copyright (c) 2012-2014 Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package com.codenvy.dev.shell.view;

import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.shell.plugin.support.DefaultPromptProvider;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/** @author Vladyslav Zhukovskii */
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class ShellPromptProvider extends DefaultPromptProvider {
    @Override
    public String getPrompt() {
        DateFormat dateFormat = new SimpleDateFormat("HH:mm");

        return String.format("[%s] :: codenvy dev $", dateFormat.format(Calendar.getInstance().getTime()));
    }

    @Override
    public String getProviderName() {
        return "ShellPromptProvider";
    }
}