package org.mvnsearch.ali.oss.spring.shell.commands;

import org.mvnsearch.ali.oss.spring.services.ConfigService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.shell.plugin.support.DefaultPromptProvider;
import org.springframework.shell.support.util.OsUtils;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * aliyun OSS prompt provider
 *
 * @author linux_china
 */
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class OssCliPromptProvider extends DefaultPromptProvider implements InitializingBean {
    /**
     * prompt
     */
    public static String prompt = "AliOSS";
    /**
     * symbol
     */
    public static String symbol = "#";

    /**
     * config service
     */
    private ConfigService configService;

    /**
     * inject config service
     *
     * @param configService config service
     */
    @Autowired
    public void setConfigService(ConfigService configService) {
        this.configService = configService;
    }

    /**
     * init method
     *
     * @throws Exception exception
     */
    public void afterPropertiesSet() throws Exception {
        String currentBucket = configService.getProperty("BUCKET");
        if (currentBucket != null) {
            prompt = "oss://" + currentBucket;
        }
        //if Windows OS, adjust symbo to '>'
        if ((OsUtils.isWindows())) {
            symbol = ">";
        }
    }

    /**
     * prompt
     *
     * @return prompt
     */
    @Override
    public String getPrompt() {
        return "[" + prompt + "]" + symbol;
    }

    /**
     * name
     *
     * @return name
     */
    @Override
    public String name() {
        return "aliyun-oss-java-cli-prompt-provider";
    }

}

@@ -47,16 +47,102 @@
 mands;%0A%0A
+import org.apache.commons.lang3.SystemUtils;%0Aimport org.jline.utils.AttributedString;%0A
 import o
@@ -193,16 +193,16 @@
 ervice;%0A
-
 import o
@@ -443,99 +443,28 @@
 ell.
-plugin.support.DefaultPromptProvider;%0Aimport org.springframework.shell.support.util.OsUtils
+jline.PromptProvider
 ;%0Aim
@@ -515,30 +515,8 @@
 t;%0A%0A
-import java.io.File;%0A%0A
 /**%0A
@@ -659,23 +659,19 @@
 der 
-extend
+implement
 s 
-Default
 Prom
@@ -680,27 +680,17 @@
 Provider
- implements
+,
  Initial
@@ -1267,25 +1267,8 @@
 et()
- throws Exception
  %7B%0A 
@@ -1465,16 +1465,17 @@
 st symbo
+l
  to '%3E'%0A
@@ -1491,27 +1491,33 @@
 f ((
-OsUtils.isWindows()
+SystemUtils.IS_OS_WINDOWS
 )) %7B
@@ -1640,24 +1640,34 @@
 %0A    public 
+Attributed
 String getPr
@@ -1690,16 +1690,37 @@
  return 
+new AttributedString(
 %22%5B%22 + pr
@@ -1742,165 +1742,9 @@
 mbol
-;%0A    %7D%0A%0A    /**%0A     * name%0A     *%0A     * @return name%0A     */%0A    @Override%0A    public String name() %7B%0A        return %22aliyun-oss-java-cli-prompt-provider%22
+)
 ;%0A  

Use PromptProvider API from 2.1.0