Class GreedyClassicGetOptParser<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>
com.github.rvesse.airline.parser.options.GreedyClassicGetOptParser<T>
- Type Parameters:
T- Command type
- All Implemented Interfaces:
OptionParser<T>
Greedy variant of the
ClassicGetOptParser that allows consuming values that could otherwise be treated as
options in their own right.
For example consider a command that defines options -a, -b and -c where -b takes a
value (i.e. {code arity = 1}) and the others are flag options. With that definition a user can provide the options as
-abc and that would result in the -a flag being set and the value of -b set to -c.
However an input of -acbfoo would set the -a and -c flags while setting the value of
-b to foo. If you prefer non-greedy behaviour use the ClassicGetOptParser instead.
- Since:
- 2.8.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanisSeparatorOrOption(ParseState<T> state, List<OptionMetadata> allowedOptions, String argsSeparator, boolean shortForm, String peekedToken) Checks whether the next value is an arguments separator or optionMethods inherited from class ClassicGetOptParser
parseOptionsMethods inherited from class AbstractOptionParser
findOption, findOption, hasShortNamePrefix, noValueForOptionMethods inherited from class AbstractParser
getTypeConverter
-
Constructor Details
-
GreedyClassicGetOptParser
public GreedyClassicGetOptParser()
-
-
Method Details
-
isSeparatorOrOption
protected boolean isSeparatorOrOption(ParseState<T> state, List<OptionMetadata> allowedOptions, String argsSeparator, boolean shortForm, String peekedToken) Description copied from class:AbstractOptionParserChecks whether the next value is an arguments separator or optionThis helps option parsers ensure they are not overly greedy when trying to consume options and their values when they should instead be raising an error because no value is provided for an option.
- Overrides:
isSeparatorOrOptionin classAbstractOptionParser<T>- Parameters:
state- Parse StateallowedOptions- Allowed optionsargsSeparator- Arguments separatorshortForm- Whether to test only for short form, iftrueonly consider the first character ofpeekedTokenpeekedToken- The peeked token to check whether it is the arguments separator or an option- Returns:
- True if the peeked token represents an arguments separator or an option
-