Class ClassicGetOptParser<T>
java.lang.Object
com.github.rvesse.airline.parser.AbstractParser<T>
com.github.rvesse.airline.parser.options.AbstractOptionParser<T>
com.github.rvesse.airline.parser.options.ClassicGetOptParser<T>
- Type Parameters:
T-
- All Implemented Interfaces:
OptionParser<T>
- Direct Known Subclasses:
GreedyClassicGetOptParser
An options parsing that parses options given in classic get-opt style where multiple options may be concatenated
together, potentially including a value for the last option in the concatenation.
This is the default variant of the parser used by default configuration and since 2.8.2 was updated to be non-greedy
in its value consumption for arity = 1 options. For the old greedy behaviour please use
GreedyClassicGetOptParser instead.
For example consider a command that defines options -a, -b and -c where -b takes a
value (i.e. arity = 1) and the others are flag options. With that definition a user can provide the options
as -abc and that would result in an error because the c is considered an option and not a value for
-b resulting in a ParseOptionMissingValueException being generated.
However an input of -acbfoo would set the -a and -c flags while setting the value of
-b to foo.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseOptions(org.apache.commons.collections4.iterators.PeekingIterator<String> tokens, ParseState<T> state, List<OptionMetadata> allowedOptions) Parses one/more options from the token streamMethods inherited from class AbstractOptionParser
findOption, findOption, hasShortNamePrefix, isSeparatorOrOption, noValueForOptionMethods inherited from class AbstractParser
getTypeConverter
-
Constructor Details
-
ClassicGetOptParser
public ClassicGetOptParser()
-
-
Method Details
-
parseOptions
public ParseState<T> parseOptions(org.apache.commons.collections4.iterators.PeekingIterator<String> tokens, ParseState<T> state, List<OptionMetadata> allowedOptions) Description copied from interface:OptionParserParses one/more options from the token stream- Parameters:
tokens- Tokensstate- Current parser stateallowedOptions- Allowed options at this point of the parsing- Returns:
- New parser state, may return
nullif this parser could not parse the next token as an option
-