Naming

If there is a need to modify option long names that can be done using OptionNameModifier interface which is a simple Function<String, String>. In this interface original option name goes in and modified name comes out.spring-doc.cn

Modifier can be defined per OptionSpec in CommandRegistration, defaulting globally as bean or via configuration properties. Modifier defined manually in OptionSpec takes takes precedence over one defined globally. There is no global modifier defined on default.spring-doc.cn

You can define one with an option in CommandRegistration.spring-doc.cn

CommandRegistration.builder()
	.withOption()
		.longNames("arg1")
		.nameModifier(name -> "x" + name)
		.and()
	.build();

Add one singleton bean as type OptionNameModifier and that becomes a global default.spring-doc.cn

@Bean
OptionNameModifier sampleOptionNameModifier() {
	return name -> "x" + name;
}

It’s also possible to just add configuration property with spring.shell.option.naming.case-type which auto-configures one based on a type defined.spring-doc.cn

noop is to do nothing, camel, snake, kebab, pascal activates build-in modifiers for camelCase, snake_case, kebab-case or PascalCase respectively.spring-doc.cn

If creating CommandRegistration beans directly, global default via configuration properies only work if using pre-configured Builder instance. See more [using-shell-commands-programmaticmodel].
spring:
  shell:
     option:
       naming:
         case-type: noop
         # case-type: camel
         # case-type: snake
         # case-type: kebab
         # case-type: pascal

For example options defined in an annotated method like this.spring-doc.cn

@ShellMethod(key = "option-naming-sample")
public void optionNamingSample(
	@ShellOption("from_snake") String snake,
	@ShellOption("fromCamel") String camel,
	@ShellOption("from-kebab") String kebab,
	@ShellOption("FromPascal") String pascal
) {}

On default help for that command shows names coming directly from @ShellOption.spring-doc.cn

OPTIONS
       --from_snake String
       [Mandatory]

       --fromCamel String
       [Mandatory]

       --from-kebab String
       [Mandatory]

       --FromPascal String
       [Mandatory]

Define spring.shell.option.naming.case-type=kebab and default modifier is added and option names then look like.spring-doc.cn

OPTIONS
       --from-snake String
       [Mandatory]

       --from-camel String
       [Mandatory]

       --from-kebab String
       [Mandatory]

       --from-pascal String
       [Mandatory]