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 = 1options. For the old greedy behaviour please useGreedyClassicGetOptParserinstead.For example consider a command that defines options
-a,-band-cwhere-btakes a value (i.e.arity = 1) and the others are flag options. With that definition a user can provide the options as-abcand that would result in an error because thecis considered an option and not a value for-bresulting in aParseOptionMissingValueExceptionbeing generated.However an input of
-acbfoowould set the-aand-cflags while setting the value of-btofoo.
-
-
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: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
-
-