For the latest stable version, please use Spring Shell 3.3.1!

Help Options

Spring Shell has a build-in help command but not all favour getting command help from it as you always need to call it with arguments for target command. It’s common in many cli frameworks for every command having options --help and -h to print out command help.

Default functionality is that every command will get modified to have options --help and -h, which if present in a given command will automatically short circuit command execution into a existing help command regardless what other command-line options is typed.

Below example shows its default settings.

@Bean
CommandRegistration commandRegistration() {
	return CommandRegistration.builder()
		.command("mycommand")
		.withHelpOptions()
			.enabled(true)
			.longNames("help")
			.shortNames('h')
			.command("help")
			.and()
		.build();
}

It is possible to change default behaviour via configuration options.

spring:
  shell:
    help:
      enabled: true
      long-names: help
      short-names: h
      command: help
Commands defined programmationally or via annotations will automatically add help options. With annotation model you can only turn things off globally, programmatic model gives option to modify settings per command.