Global restrictions apply over the final parser state and are used to implement restrictions that need to see this final state. The following built-in defaults are provided and used by default for all CLIs and commands unless otherwise specified:
@CommandRequired
annotation indicates that a command must be specified.@NoMissingOptionValues
annotation indicates that specifying an option without its corresponding value(s) is not permitted.@NoUnexpectedArguments
annotation indicates that any unrecognised inputs are not permitted.These provide useful default behaviours that most developers will expect from the CLIs they are building.
For CLIs you can set the desired restrictions via the restrictions
field of the @Cli
annotation and control whether the defaults are included via its includeDefaultRestrictions
field.
Or you can add the relevant annotations to the class that has the @Cli
annotation and they will be automatically detected.
For single commands you can specify global restrictions directly on @Command
annotated classes and these will be automatically detected appropriately.
As with other kinds of restrictions you can create custom Global restrictions if desired, the Custom Restrictions documentation describes the necessary steps for this.
This documentation is itself open source and lives in GitHub under the docs/ directory.
I am not a professional technical writer and as the developer of this software I can often make assumptions of
knowledge that you as a user reading this may not have. Improvements to the documentation are always welcome, if you
have suggestions for the documentation please submit pull requests to the main
branch.