Module com.github.rvesse.airline
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
public class ClassicGetOptParser<T> extends AbstractOptionParser<T>
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 useGreedyClassicGetOptParser
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 thec
is considered an option and not a value for-b
resulting in aParseOptionMissingValueException
being generated.However an input of
-acbfoo
would set the-a
and-c
flags while setting the value of-b
tofoo
.
-
-
Constructor Summary
Constructors Constructor Description ClassicGetOptParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParseState<T>
parseOptions(org.apache.commons.collections4.iterators.PeekingIterator<java.lang.String> tokens, ParseState<T> state, java.util.List<OptionMetadata> allowedOptions)
Parses one/more options from the token stream-
Methods inherited from class com.github.rvesse.airline.parser.options.AbstractOptionParser
findOption, findOption, hasShortNamePrefix, isSeparatorOrOption, noValueForOption
-
Methods inherited from class com.github.rvesse.airline.parser.AbstractParser
getTypeConverter
-
-
-
-
Method Detail
-
parseOptions
public ParseState<T> parseOptions(org.apache.commons.collections4.iterators.PeekingIterator<java.lang.String> tokens, ParseState<T> state, java.util.List<OptionMetadata> allowedOptions)
Description copied from interface:OptionParser
Parses 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
null
if this parser could not parse the next token as an option
-
-