Command template inheritance
As previously mentioned, a command template must always inherit from CommandTemplate
. However, it must be noted that a template class can inherit from any other class as long as in the end of the inheritance chain there is a class that extends CommandTemplate
. This can be useful for creating more "generic" command templates that can be used as a base for other command templates.
Example
Here's a command template that just defines a command with two arguments, related to a user:
We can now create a brand new command template that inherits from UserCommand
and adds a new argument to it:
The StudentCommand
class now has all the arguments that UserCommand
has, plus a new one.
Default command templates
Lanat provides a few default command templates that you can inherit from;
CommandTemplate.Default
Very common command template as it adds the help
and version
arguments to the command. This essentially just calls Command#addHelpArgument
and Command#addVersionArgument
in the afterInit
method.
CommandTemplate.Default.WithVerbose
Inherits from CommandTemplate.Default
and adds a verbose
argument to the command as well.
The verbose
/v
argument has a type of CounterArgumentType
, which means that it can be used multiple times to increase the verbosity of the command.