Then we need to create the application class, that will start up the shell.
package shell;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
Because we are using Spring Boot, the application will now get all the beans that are annotated with @ShellComponent annotation and will try to use them as commands in the shell. Lets create one.
package shell.command;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;
@ShellComponent
public class TestCommand {
@ShellMethod(key = "test", value = "Test command")
public String test() {
return "Hello world!";
}
}