T - Command typepublic class GreedyClassicGetOptParser<T> extends ClassicGetOptParser<T>
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.
| Constructor and Description |
|---|
GreedyClassicGetOptParser() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
isSeparatorOrOption(ParseState<T> state,
List<OptionMetadata> allowedOptions,
String argsSeparator,
boolean shortForm,
String peekedToken)
Checks whether the next value is an arguments separator or option
|
parseOptionsfindOption, findOption, hasShortNamePrefix, noValueForOptiongetTypeConverterprotected boolean isSeparatorOrOption(ParseState<T> state, List<OptionMetadata> allowedOptions, String argsSeparator, boolean shortForm, String peekedToken)
AbstractOptionParserThis 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.
isSeparatorOrOption in class AbstractOptionParser<T>state - Parse StateallowedOptions - Allowed optionsargsSeparator - Arguments separatorshortForm - Whether to test only for short form, if true only consider the first character of
peekedTokenpeekedToken - The peeked token to check whether it is the arguments separator or an optionCopyright © 2012–2022. All rights reserved.