It is typical for commandline applications to handle multiple related tasks within a single problem domain. Each such task - in our terminology subcommand - usually uses different set of options, attributes and properties, and therefore it makes sense to explicitly support the fact that subcommand argument is something a bit different from options and values.
This approach is very common - you can see it on
Subcommand is represented with a java object implementing interface ArgsCommand. This object is
During excution, it can throw any exception; with default processing, this is trapped and causes the application to exit JVM with exit code of 1.
Each subcommand typically has at least one name. It can be also unnamed, but then it is only usable as the default subcommand.
Alternative names can be added, to serve convenience or compatibility purposes - see @SubCommand.aliases().
Application can define a default subcommand. The effect is following:
- if the first parameter after option extraction does not equal to a known command name, the control is passed to the default subcommand.
If the default subcommand does not have any name declared, it causes that there is no other way to invoke it than as the default - that is, implicitly.
And if there is no other subcommand defined, the whole application serves as single-functionality invoker - something like java, javac and many many more.
... read more at Default help command page.