Once Annotation

@Once

The @Once annotation is used to indicate that an @Option or @Arguments may be specified at most once.

@Option(name = "--name",
        arity = 1,
        title = "Name")
@Once
private String name;

Here we specify that the --name option may only be provided once. If the user specifies it more than once then an error will be thrown during parsing.

Since this acts as a maximum the user is not required to specify the option, if you want to require that the option occur then use the @Required annotation.

To specify the minimum number of occurrences you can use the @MinOccurrences annotation or for maximum number of occurrences the @MaxOccurrences 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.