diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java index 18728d79..f104dc81 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java @@ -40,6 +40,6 @@ import org.springframework.shell.result.ResultHandlerConfig; public class SpringShellSample { public static void main(String[] args) throws Exception { - ConfigurableApplicationContext context = SpringApplication.run(SpringShellSample.class); + ConfigurableApplicationContext context = SpringApplication.run(SpringShellSample.class, args); } } diff --git a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Console.java b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Clear.java similarity index 71% rename from spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Console.java rename to spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Clear.java index 5cf6d41a..ef16d8af 100644 --- a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Console.java +++ b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Clear.java @@ -30,7 +30,20 @@ import org.springframework.shell.standard.ShellMethod; * @author Eric Bottard */ @ShellComponent -public class Console { +public class Clear { + + /** + * Marker interface for beans providing {@literal clear} functionality to the shell. + * + *
To override the clear command, simply register your own bean implementing that interface + * and the standard implementation will back off.
+ * + *To disable the {@literal clear} command entirely, set the {@literal spring.shell.command.clear.enabled=false} + * property in the environment.
+ * + * @author Eric Bottard + */ + public interface Command {} @Autowired @Lazy private Terminal terminal; diff --git a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Help.java b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Help.java index c351ff2e..827a1859 100644 --- a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Help.java +++ b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Help.java @@ -49,6 +49,19 @@ import org.springframework.shell.Utils; @ShellComponent public class Help { + /** + * Marker interface for beans providing {@literal help} functionality to the shell. + * + *To override the help command, simply register your own bean implementing that interface + * and the standard implementation will back off.
+ * + *To disable the {@literal help} command entirely, set the {@literal spring.shell.command.help.enabled=false} + * property in the environment.
+ * + * @author Eric Bottard + */ + public interface Command {} + private final ListTo override the quit command, simply register your own bean implementing that interface + * and the standard implementation will back off.
+ * + *To disable the {@literal quit} command entirely, set the {@literal spring.shell.command.quit.enabled=false} + * property in the environment.
+ * + * @author Eric Bottard + */ + public interface Command {} + @ShellMethod(help = "Exit the shell.", value = {"quit", "exit"}) public void quit() { throw new ExitRequest(); diff --git a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Stacktrace.java b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Stacktrace.java index 9959d36a..3b52c2e3 100644 --- a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Stacktrace.java +++ b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/Stacktrace.java @@ -30,6 +30,19 @@ import org.springframework.shell.standard.ShellMethod; @ShellComponent public class Stacktrace { + /** + * Marker interface for beans providing {@literal stacktrace} functionality to the shell. + * + *To override the stacktrace command, simply register your own bean implementing that interface + * and the standard implementation will back off.
+ * + *To disable the {@literal stacktrace} command entirely, set the {@literal spring.shell.command.stacktrace.enabled=false} + * property in the environment.
+ * + * @author Eric Bottard + */ + public interface Command {} + @Autowired @Lazy private Terminal terminal; diff --git a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/StandardCommandsAutoConfiguration.java b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/StandardCommandsAutoConfiguration.java index c66ca942..04f2cbc5 100644 --- a/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/StandardCommandsAutoConfiguration.java +++ b/spring-shell-standard-commands/src/main/java/org/springframework/shell/standard/commands/StandardCommandsAutoConfiguration.java @@ -18,6 +18,8 @@ package org.springframework.shell.standard.commands; import java.util.List; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.shell.ParameterResolver; @@ -31,21 +33,29 @@ import org.springframework.shell.ParameterResolver; public class StandardCommandsAutoConfiguration { @Bean + @ConditionalOnMissingBean(Help.Command.class) + @ConditionalOnProperty(prefix = "spring.shell.command.help", value = "enabled", havingValue = "true", matchIfMissing = true) public Help help(List