I am using Spring Shell 3.0.0 to implement a command line application. The application deals with several types of objects and has several commands for each type of object, for example:
list-foos
list-bars
describe-foo XYZ
To improve usability, I would like to change the syntax to
foo list
bar list
foo describe XYZ
I understand that commands can be grouped and am using this functionality, which improves the help text, but as far as I can tell doesn't do anything beyond that.
I could implement this as separate top level foo
and bar
commands that take the subcommand as a positional parameter, but am looking for a better way. For example, I'd like to be able to define each subcommand as its own method (e.g. using @ShellMethod
) so it can have its own parameters, help text, availability, etc.
The documentation implies there is support for sub commands:
A command in a spring-shell structure is defined as an array of commands. This yields a structure
similar to the following example:
command1 sub1
command2 sub1 subsub1
command2 sub2 subsub1
command2 sub2 subsub2
But I haven't been able to figure out how to make this work. Curious if this is possible and if so how to set it up? Ideally, I'd like typing foo
to show a list of subcommands, help foo
to show help on those commands, etc.