Annotations

Airline uses a variety of different annotations to allow you to declaratively define various aspects of your CLIs. This section of the user guide covers each annotation in-depth with examples of their practical usage.

CLI Annotations

The following annotations are used to define the high level aspects of your CLIs:

Restriction Annotations

The following annotations are used to define various restrictions on options and arguments that cause Airline to automatically enforce restrictions on their usage e.g. requiring an option take a value from a restricted set of values.

All these annotations are applied to fields that are annotated with @Option or @Arguments and are automatically discovered during meta-data extraction. If you are overriding the definition of an option then restrictions are automatically inherited unless you specify new restrictions further as part of your override. In the case where you wish to remove inherited restrictions you can use the special @Unrestricted annotation to indicate that.

Requirement Restrictions

The following annotations are used to specify that options/arguments (or combinations thereof) are required:

Occurrence Restrictions

The following annotations are used to specify the number of times that options/arguments can be specified:

Value Restrictions

The following annotations are used to specify restrictions on the values for options/arguments:

Range Value Restrictions

A further subset of annotations specify restrictions on the values for options/arguments in terms of ranges of acceptable values:

Special Restrictions

The following are special purpose restrictions:

Global Restrictions

The following are Global restrictions which apply over the final parser state:

Help Annotations

The following annotations are used to add additional help information to commands that may be consumed by the various help generators provided by Airline by producing additional help sections.

All these annotations are added to an @Command annotated class or a parent class in the commands hierarchy. They are automatically discovered from a command classes inheritance hierarchy, where an annotation occurs more than once the annotation specified furthest down the hierarchy is used. This can be used to specify a default for some help annotation with the option of overriding it if necessary, the special @HideSection annotation may be used to suppress an inherited help annotation.


Improving this Documentation

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.