1. Short Format
Short style POSIX option in most is just a synonym to long format but
adds additional feature to combine those options together. Having short
options a, b, c can be used as -abc.
Programmatically short option is defined by using short name function.
CommandRegistration.builder()
.withOption()
.shortNames('a')
.and()
.withOption()
.shortNames('b')
.and()
.withOption()
.shortNames('c')
.and()
.build();
Short option with combined format is powerful if type is defined as a flag
which means type is a boolean. That way you can define a presense of a flags
as -abc, -abc true or -abc false.
CommandRegistration.builder()
.withOption()
.shortNames('a')
.type(boolean.class)
.and()
.withOption()
.shortNames('b')
.type(boolean.class)
.and()
.withOption()
.shortNames('c')
.type(boolean.class)
.and()
.build();
With annotation model you can define short argument directly.
public String example(
@ShellOption(value = { "-a" }) String arg1,
@ShellOption(value = { "-b" }) String arg2,
@ShellOption(value = { "-c" }) String arg3
) {
return "Hello " + arg1;
}