Annotation Interface NoOptionLikeValues
Remember that Airline parsers are generally conservative in that if they are trying to consume values and the next value matches a known option they will produce an appropriate error. However this does not protect against user error, e.g. user making a typo in their options, in that case the value would still be consumed. This can often lead to unexpected behaviour because it can cause something the user expected to be an option to be treated as a value meaning all subsequent arguments provided may also be misinterpreted. Sometimes this can cause many parser errors to be produced, none of which actually identified the root cause of the problems. Using this restriction prevents that scenario since any value that looks like it could be an option will not be consumed and produce an appropriate error instead.
This restriction can be used as either an Option/Argument level restriction, or as a Global restriction. When used as an Option/Argument level restriction it operates upon the raw values prior to their parsing into the appropriate value type for the Option/Argument. When used as a Global restriction it operates upon the typed values that have been assigned to each parsed option.
This distinction can be quite important when options/arguments can legitimately take values that appear option like.
For example consider an option typed as Integer
, users may legitimately expect to be able to pass in negative
numbers to this option. If that option were to have this restriction applied directly to it any negative numbers
would be rejected since -
is considered an option prefix. However were this restriction instead applied at
the command/CLI level, i.e. made global, then negative numbers would be permitted because it would only consider the
typed values for the options. As the typed value for the option is an Integer
the restriction would not be
applied to it.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]
Indicates the prefixes that will be used to detect values that look like options.
-
Element Details
-
optionPrefixes
String[] optionPrefixesIndicates the prefixes that will be used to detect values that look like options. If a value starts with any of these prefixes then it will be rejected.If not specified then the default prefixes are
-
and--
- Returns:
- Option Prefixes
- Default:
{"-", "--"}
-