This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Shell 3.4.1!

Annotation

The @Command annotation marks a method as a candidate for command registration. In below example a command example is defined.

class Example1 {

	@Command(name = "example")
	public String example() {
		return "Hello";
	}

}

Using a @Command will not automatically register command targets, instead it is required to use @EnableCommand annotations. This model is familiar from other parts of Spring umbrella and provides better flexibility for a user being inclusive rather than exclusive for command targets.

You can define target classes using @EnableCommand. It will get picked from all Configuration classes.

@EnableCommand({ Example1.class, Example2.class })
class App {

}
@EnableCommand is not required in a Spring Boot application, as Spring Boot auto-configuration will take care of that.