Reputation: 63
is it possible to change the prompt in a spring shell application? For default it seems that the prompt is:
shell:>
Is is possible to change this text at runtime?
THX
Upvotes: 2
Views: 1487
Reputation: 670
What worked for me:
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.jline.PromptProvider;
import org.jline.utils.AttributedString;
@Configuration
public class SpringShellConfiguration implements PromptProvider {
@Override
public final AttributedString getPrompt() {
return new AttributedString("myapp:> ");
}
}
Upvotes: 0
Reputation: 63
Thank you for the answer! I've overlooked this feature. I created this class, put it into my configuration-package and it works good for me:
package de.myapp.spring.configuration;
@Configuration
@ComponentScan("de.myapp.spring.shell")
public class ShellApplicationConfiguration implements PromptProvider {
@Override
public final AttributedString getPrompt() {
return new AttributedString("myapp:>");
}
}
Upvotes: 4
Reputation: 144
You can define a PromptProvider
, see in the Docs: https://docs.spring.io/spring-shell/docs/current-SNAPSHOT/reference/htmlsingle/#_promptprovider
Upvotes: 1