Add PromptProvider extension point

This commit is contained in:
Eric Bottard
2017-08-08 16:07:12 +02:00
parent 75911b5fed
commit c3c7f1fccd
6 changed files with 43 additions and 18 deletions

View File

@@ -16,18 +16,14 @@
package org.springframework.shell.samples;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStyle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.shell.Shell;
import org.springframework.shell.jline.JLineShell;
import org.springframework.shell.result.ResultHandlerConfig;
import org.springframework.shell.jline.PromptProvider;
/**
* Main entry point for the application.
@@ -42,4 +38,9 @@ public class SpringShellSample {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(SpringShellSample.class, args);
}
@Bean
public PromptProvider myPromptProvider() {
return () -> new AttributedString("my-shell:>", AttributedStyle.DEFAULT.foreground(AttributedStyle.YELLOW));
}
}