Module com.github.rvesse.airline
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>
public class GreedyClassicGetOptParser<T> extends ClassicGetOptParser<T>
Greedy variant of theClassicGetOptParserthat allows consuming values that could otherwise be treated as options in their own right.For example consider a command that defines options
-a,-band-cwhere-btakes a value (i.e. {code arity = 1}) and the others are flag options. With that definition a user can provide the options as-abcand that would result in the-aflag being set and the value of-bset to-c.However an input of
-acbfoowould set the-aand-cflags while setting the value of-btofoo. If you prefer non-greedy behaviour use theClassicGetOptParserinstead.- Since:
- 2.8.2
-
-
Constructor Summary
Constructors Constructor Description GreedyClassicGetOptParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisSeparatorOrOption(ParseState<T> state, java.util.List<OptionMetadata> allowedOptions, java.lang.String argsSeparator, boolean shortForm, java.lang.String peekedToken)Checks whether the next value is an arguments separator or option-
Methods inherited from class com.github.rvesse.airline.parser.options.ClassicGetOptParser
parseOptions
-
Methods inherited from class com.github.rvesse.airline.parser.options.AbstractOptionParser
findOption, findOption, hasShortNamePrefix, noValueForOption
-
Methods inherited from class com.github.rvesse.airline.parser.AbstractParser
getTypeConverter
-
-
-
-
Method Detail
-
isSeparatorOrOption
protected boolean isSeparatorOrOption(ParseState<T> state, java.util.List<OptionMetadata> allowedOptions, java.lang.String argsSeparator, boolean shortForm, java.lang.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
-
-