Class CommandLine.Model.ArgSpec
- java.lang.Object
-
- picocli.CommandLine.Model.ArgSpec
-
- Direct Known Subclasses:
CommandLine.Model.OptionSpec
,CommandLine.Model.PositionalParamSpec
- Enclosing class:
- CommandLine.Model
public abstract static class CommandLine.Model.ArgSpec extends java.lang.Object
Models the shared attributes ofCommandLine.Model.OptionSpec
andCommandLine.Model.PositionalParamSpec
.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
CommandLine.Model.ArgSpec.Builder<T extends CommandLine.Model.ArgSpec.Builder<T>>
-
Field Summary
Fields Modifier and Type Field Description protected CommandLine.Model.IAnnotatedElement
annotatedElement
private CommandLine.Range
arity
(package private) CommandLine.Model.CommandSpec
commandSpec
private java.lang.Iterable<java.lang.String>
completionCandidates
private CommandLine.ITypeConverter<?>[]
converters
private java.lang.String
defaultValue
private java.lang.String[]
description
(package private) static java.lang.String
DESCRIPTION_VARIABLE_COMPLETION_CANDIDATES
(package private) static java.lang.String
DESCRIPTION_VARIABLE_DEFAULT_VALUE
(package private) static java.lang.String
DESCRIPTION_VARIABLE_FALLBACK_VALUE
(package private) static java.lang.String
DESCRIPTION_VARIABLE_MAP_FALLBACK_VALUE
private java.lang.String
descriptionKey
private boolean
echo
private CommandLine.Model.IGetter
getter
private CommandLine.Model.ArgGroupSpec
group
private boolean
hasInitialValue
private boolean
hidden
private boolean
hideParamSyntax
private boolean
inherited
private java.lang.Object
initialValue
private CommandLine.Model.InitialValueState
initialValueState
private boolean
interactive
private java.lang.String
mapFallbackValue
private CommandLine.Model.Messages
messages
private static java.lang.String
NO_DEFAULT_VALUE
(package private) static java.lang.String
NULL_VALUE
Special value that can be used to designatenull
.private java.util.List<java.lang.String>
originalStringValues
private CommandLine.IParameterConsumer
parameterConsumer
private java.lang.String
paramLabel
private CommandLine.IParameterPreprocessor
preprocessor
private java.lang.String
prompt
private boolean
required
private CommandLine.Model.ArgSpec
root
private CommandLine.Model.IScope
scope
private CommandLine.ScopeType
scopeType
private CommandLine.Model.ISetter
setter
private CommandLine.Help.Visibility
showDefaultValue
private java.lang.String
splitRegex
private java.lang.String
splitRegexSynopsisLabel
private java.util.List<java.lang.String>
stringValues
protected java.lang.String
toString
(package private) java.util.Map<java.lang.Integer,java.lang.Object>
typedValueAtPosition
private java.util.List<java.lang.Object>
typedValues
protected CommandLine.Model.ITypeInfo
typeInfo
private static java.lang.String
UNSPECIFIED
private java.lang.Object
userObject
-
Constructor Summary
Constructors Modifier Constructor Description private
ArgSpec(CommandLine.Model.ArgSpec.Builder<T> builder)
Constructs a newArgSpec
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) void
applyInitialValue(CommandLine.Tracer tracer)
CommandLine.Range
arity()
Returns how many arguments this option or positional parameter requires.java.lang.Class<?>[]
auxiliaryTypes()
private java.lang.Object
calcDefaultValue(boolean interpolate)
CommandLine.Model.CommandSpec
command()
Returns the command this option or positional parameter belongs to.java.lang.Iterable<java.lang.String>
completionCandidates()
Returns the explicitly set completion candidates for this option or positional parameter, valid enum constant names, ornull
if this option or positional parameter does not have any completion candidates and its type is not an enum.CommandLine.ITypeConverter<?>[]
converters()
Returns one or moretype converters
to use to convert the command line argument into a strongly typed value (or key-value pair for map fields).private java.lang.String[]
debug(java.lang.String[] result, java.lang.String msg, java.lang.String value)
java.lang.String
defaultValue()
Returns the default value to assign if this option or positional parameter was not specified on the command line, before splitting and type conversion.private java.lang.String
defaultValueFromProvider()
java.lang.String
defaultValueString()
Returns the default value String for the purpose of displaying it in the description, without interpolating variables.java.lang.String
defaultValueString(boolean interpolateVariables)
Returns the default value String displayed in the description; interpolating variables if specified.private static java.lang.String
describe(java.util.Collection<CommandLine.Model.ArgSpec> args)
private static java.lang.String
describe(java.util.Collection<CommandLine.Model.ArgSpec> args, java.lang.String separator, java.lang.String optionParamSeparator, java.lang.String openingQuote, java.lang.String closingQuote)
private static java.lang.String
describe(CommandLine.Model.ArgSpec argSpec, java.lang.String separator)
Returns a description of the option or positional arg, e.g.private static java.lang.String
describe(CommandLine.Model.ArgSpec argSpec, java.lang.String separator, java.lang.String value)
Returns a description of the option or positional argprivate static java.lang.String
describeTypes(java.util.Collection<CommandLine.Model.ArgSpec> args)
java.lang.String[]
description()
Returns the description of this option or positional parameter, after all variables have been rendered, including the${DEFAULT-VALUE}
and${COMPLETION-CANDIDATES}
variables.java.lang.String
descriptionKey()
Returns the description key of this arg spec, used to get the description from a resource bundle.boolean
echo()
Returns whether the user input is echoed to the console or not for an interactive option or positional parameter when asking for user input.protected boolean
equalsImpl(CommandLine.Model.ArgSpec other)
private java.lang.String[]
expandVariables(java.lang.String[] desc)
protected abstract java.util.Collection<java.lang.String>
getAdditionalDescriptionKeys()
Subclasses should override to return a collection of additional description keys that may be used to find description text for this option or positional parameter in the resource bundle.CommandLine.Model.IGetter
getter()
Returns theCommandLine.Model.IGetter
that is responsible for supplying the value of this argument.<T> T
getValue()
Returns the current value of this argument.CommandLine.Model.ArgGroupSpec
group()
Returns the groups this option or positional parameter belongs to, ornull
if this option is not part of a group.protected int
hashCodeImpl()
boolean
hasInitialValue()
Determines whether the option or positional parameter will be reset to theinitialValue()
before parsing new input.boolean
hidden()
Returns whether this option should be excluded from the usage message.boolean
hideParamSyntax()
Returns whether usage syntax decorations around the paramLabel should be suppressed.boolean
inherited()
Returns whether this option is inherited from a parent command.java.lang.Object
initialValue()
Returns the initial value of this option or positional parameter: the value that, ifhasInitialValue()
is true, the option will be reset to before parsing (regardless of whether a default value exists), to clear values that would otherwise remain from parsing previous input.boolean
interactive()
Returns whether this option will prompt the user to enter a value on the command line.protected boolean
internalShowDefaultValue(boolean usageHelpShowDefaults)
Returns whether the default for this option or positional parameter should be shown, potentially overriding the specified global setting.(package private) java.lang.String
interpolate(java.lang.String value)
(package private) java.lang.String[]
interpolate(java.lang.String[] values)
boolean
isMultiValue()
abstract boolean
isOption()
Returnstrue
if this argument is a named option,false
otherwise.abstract boolean
isPositional()
Returnstrue
if this argument is a positional parameter,false
otherwise.java.lang.String
mapFallbackValue()
Returns the fallback value for this Map option or positional parameter: the value that is put into the Map when only the key is specified for the option or positional parameter, like-Dkey
instead of-Dkey=value
.CommandLine.Model.Messages
messages()
Returns the Messages for this arg specification, ornull
.CommandLine.Model.ArgSpec
messages(CommandLine.Model.Messages msgs)
Sets the Messages for this ArgSpec, and returns this ArgSpec.java.util.List<java.lang.String>
originalStringValues()
Returns the original command line arguments matched by this option or positional parameter spec.CommandLine.IParameterConsumer
parameterConsumer()
Returns a customIParameterConsumer
to temporarily suspend picocli's parsing logic and process one or more command line arguments in a custom manner, ornull
.java.lang.String
paramLabel()
Returns the name of the option or positional parameter used in the usage help message.CommandLine.IParameterPreprocessor
preprocessor()
Returns a customIParameterPreprocessor
to either replace or complement picocli's parsing logic for the parameter(s) of this option or position.java.lang.String
prompt()
Returns the text displayed to the end user for an interactive option or positional parameter when asking for user input.java.lang.String[]
renderedDescription()
Deprecated.Usedescription()
insteadboolean
required()
Returns whether this is a required option or positional parameter without a default value.protected void
resetOriginalStringValues()
Sets theoriginalStringValues
to a new list instance.protected void
resetStringValues()
Sets thestringValues
to a new list instance.private static java.lang.String
restoreQuotedValues(java.lang.String part, java.util.Queue<java.lang.String> quotedValues, CommandLine.Model.ParserSpec parser)
CommandLine.Model.ArgSpec
root()
Returns the root option or positional parameter (on the parent command), if this option or positional parameter was inherited; ornull
if it was not.CommandLine.Model.IScope
scope()
Returns the bindingCommandLine.Model.IScope
that determines on which object to set the value (or from which object to get the value) of this argument.private java.lang.String
scopeString()
CommandLine.ScopeType
scopeType()
Returns the scope of this argument; it it local, or inherited (it applies to this command as well as all sub- and sub-subcommands).CommandLine.Model.ISetter
setter()
Returns theCommandLine.Model.ISetter
that is responsible for modifying the value of this argument.<T> T
setValue(T newValue)
Sets the value of this argument to the specified value and returns the previous value.<T> T
setValue(T newValue, CommandLine commandLine)
Deprecated.usesetValue(Object)
instead.CommandLine.Help.Visibility
showDefaultValue()
Returns whether this option or positional parameter's default value should be shown in the usage help.java.lang.String
splitRegex()
Returns a regular expression to split option parameter values or""
if the value should not be split.java.lang.String
splitRegexSynopsisLabel()
Returns a regular expression to split option parameter for usage information.private static java.lang.String[]
splitRespectingQuotedStrings(java.lang.String value, int limit, CommandLine.Model.ParserSpec parser, CommandLine.Model.ArgSpec argSpec, java.lang.String splitRegex)
(package private) java.lang.String[]
splitValue(java.lang.String value, CommandLine.Model.ParserSpec parser, CommandLine.Range arity, int consumed)
java.util.List<java.lang.String>
stringValues()
Returns the untyped command line arguments matched by this option or positional parameter spec.java.lang.String
toString()
Returns a string respresentation of this option or positional parameter.java.lang.Class<?>
type()
Returns the type to convert the option or positional parameter to before setting the value.java.util.List<java.lang.Object>
typedValues()
Returns the typed command line arguments matched by this option or positional parameter spec.CommandLine.Model.ITypeInfo
typeInfo()
Returns theITypeInfo
that can be used both at compile time (by annotation processors) and at runtime.java.lang.Object
userObject()
Returns the user object associated with this option or positional parameters.
-
-
-
Field Detail
-
NULL_VALUE
static final java.lang.String NULL_VALUE
Special value that can be used to designatenull
.
-
DESCRIPTION_VARIABLE_DEFAULT_VALUE
static final java.lang.String DESCRIPTION_VARIABLE_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
DESCRIPTION_VARIABLE_FALLBACK_VALUE
static final java.lang.String DESCRIPTION_VARIABLE_FALLBACK_VALUE
- See Also:
- Constant Field Values
-
DESCRIPTION_VARIABLE_MAP_FALLBACK_VALUE
static final java.lang.String DESCRIPTION_VARIABLE_MAP_FALLBACK_VALUE
- See Also:
- Constant Field Values
-
DESCRIPTION_VARIABLE_COMPLETION_CANDIDATES
static final java.lang.String DESCRIPTION_VARIABLE_COMPLETION_CANDIDATES
- See Also:
- Constant Field Values
-
NO_DEFAULT_VALUE
private static final java.lang.String NO_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
UNSPECIFIED
private static final java.lang.String UNSPECIFIED
- See Also:
- Constant Field Values
-
inherited
private final boolean inherited
-
root
private final CommandLine.Model.ArgSpec root
-
hidden
private final boolean hidden
-
paramLabel
private final java.lang.String paramLabel
-
hideParamSyntax
private final boolean hideParamSyntax
-
description
private final java.lang.String[] description
-
descriptionKey
private final java.lang.String descriptionKey
-
showDefaultValue
private final CommandLine.Help.Visibility showDefaultValue
-
messages
private CommandLine.Model.Messages messages
-
commandSpec
CommandLine.Model.CommandSpec commandSpec
-
group
private CommandLine.Model.ArgGroupSpec group
-
userObject
private final java.lang.Object userObject
-
required
private boolean required
-
interactive
private final boolean interactive
-
echo
private final boolean echo
-
prompt
private final java.lang.String prompt
-
splitRegex
private final java.lang.String splitRegex
-
splitRegexSynopsisLabel
private final java.lang.String splitRegexSynopsisLabel
-
typeInfo
protected final CommandLine.Model.ITypeInfo typeInfo
-
converters
private final CommandLine.ITypeConverter<?>[] converters
-
completionCandidates
private final java.lang.Iterable<java.lang.String> completionCandidates
-
parameterConsumer
private final CommandLine.IParameterConsumer parameterConsumer
-
preprocessor
private final CommandLine.IParameterPreprocessor preprocessor
-
mapFallbackValue
private final java.lang.String mapFallbackValue
-
defaultValue
private final java.lang.String defaultValue
-
initialValue
private java.lang.Object initialValue
-
hasInitialValue
private final boolean hasInitialValue
-
initialValueState
private CommandLine.Model.InitialValueState initialValueState
-
annotatedElement
protected final CommandLine.Model.IAnnotatedElement annotatedElement
-
getter
private final CommandLine.Model.IGetter getter
-
setter
private final CommandLine.Model.ISetter setter
-
scope
private final CommandLine.Model.IScope scope
-
scopeType
private final CommandLine.ScopeType scopeType
-
arity
private CommandLine.Range arity
-
stringValues
private java.util.List<java.lang.String> stringValues
-
originalStringValues
private java.util.List<java.lang.String> originalStringValues
-
toString
protected java.lang.String toString
-
typedValues
private final java.util.List<java.lang.Object> typedValues
-
typedValueAtPosition
java.util.Map<java.lang.Integer,java.lang.Object> typedValueAtPosition
-
-
Constructor Detail
-
ArgSpec
private ArgSpec(CommandLine.Model.ArgSpec.Builder<T> builder)
Constructs a newArgSpec
.
-
-
Method Detail
-
applyInitialValue
void applyInitialValue(CommandLine.Tracer tracer)
-
required
public boolean required()
Returns whether this is a required option or positional parameter without a default value. If this argument is part of a group, this method returns whether this argument is required within the group (so it is not necessarily a required argument for the command).- See Also:
CommandLine.Option.required()
-
interactive
public boolean interactive()
Returns whether this option will prompt the user to enter a value on the command line.
-
echo
public boolean echo()
Returns whether the user input is echoed to the console or not for an interactive option or positional parameter when asking for user input.- Since:
- 4.6
- See Also:
CommandLine.Option.echo()
,CommandLine.Parameters.echo()
-
prompt
public java.lang.String prompt()
Returns the text displayed to the end user for an interactive option or positional parameter when asking for user input.- Since:
- 4.6
- See Also:
CommandLine.Option.prompt()
,CommandLine.Parameters.prompt()
-
description
public java.lang.String[] description()
Returns the description of this option or positional parameter, after all variables have been rendered, including the${DEFAULT-VALUE}
and${COMPLETION-CANDIDATES}
variables. UseCommandLine.Model.CommandSpec.interpolateVariables(Boolean)
to switch off variable expansion if needed.If a resource bundle has been set, this method will first try to find a value in the resource bundle: If the resource bundle has no entry for the
fully qualified commandName + "." + descriptionKey
or for the unqualifieddescriptionKey
, an attempt is made to find the option or positional parameter description using any of the additional description keys, first with thefully qualified commandName + "."
prefix, then without.
-
getAdditionalDescriptionKeys
protected abstract java.util.Collection<java.lang.String> getAdditionalDescriptionKeys()
Subclasses should override to return a collection of additional description keys that may be used to find description text for this option or positional parameter in the resource bundle.
-
descriptionKey
public java.lang.String descriptionKey()
Returns the description key of this arg spec, used to get the description from a resource bundle.- Since:
- 3.6
- See Also:
CommandLine.Option.descriptionKey()
,CommandLine.Parameters.descriptionKey()
-
expandVariables
private java.lang.String[] expandVariables(java.lang.String[] desc)
-
renderedDescription
@Deprecated public java.lang.String[] renderedDescription()
Deprecated.Usedescription()
instead
-
arity
public CommandLine.Range arity()
Returns how many arguments this option or positional parameter requires.- See Also:
CommandLine.Option.arity()
-
paramLabel
public java.lang.String paramLabel()
Returns the name of the option or positional parameter used in the usage help message.- See Also:
CommandLine.Option.paramLabel()
-
hideParamSyntax
public boolean hideParamSyntax()
Returns whether usage syntax decorations around the paramLabel should be suppressed. The default isfalse
: by default, the paramLabel is surrounded with'['
and']'
characters if the value is optional and followed by ellipses ("...") when multiple values can be specified.- Since:
- 3.6.0
-
auxiliaryTypes
public java.lang.Class<?>[] auxiliaryTypes()
Returns auxiliary type information used when thetype()
is a generic type likeCollection
,Map
orOptional
; returns the concrete type whentype()
is an abstract class, otherwise, returns the same astype()
.- See Also:
CommandLine.Option.type()
-
converters
public CommandLine.ITypeConverter<?>[] converters()
Returns one or moretype converters
to use to convert the command line argument into a strongly typed value (or key-value pair for map fields). This is useful when a particular option or positional parameter should use a custom conversion that is different from the normal conversion for the arg spec's type.- See Also:
CommandLine.Option.converter()
-
splitRegex
public java.lang.String splitRegex()
Returns a regular expression to split option parameter values or""
if the value should not be split.- See Also:
CommandLine.Option.split()
-
splitRegexSynopsisLabel
public java.lang.String splitRegexSynopsisLabel()
Returns a regular expression to split option parameter for usage information.- Since:
- 4.3
- See Also:
CommandLine.Option.splitSynopsisLabel()
-
hidden
public boolean hidden()
Returns whether this option should be excluded from the usage message.- See Also:
CommandLine.Option.hidden()
-
inherited
public boolean inherited()
Returns whether this option is inherited from a parent command.- Since:
- 4.3.0
- See Also:
CommandLine.Option.scope()
-
root
public CommandLine.Model.ArgSpec root()
Returns the root option or positional parameter (on the parent command), if this option or positional parameter was inherited; ornull
if it was not.- Since:
- 4.6.1
- See Also:
CommandLine.Option.scope()
-
type
public java.lang.Class<?> type()
Returns the type to convert the option or positional parameter to before setting the value. This may be a container type likeList
,Map
, orOptional
, in which case the type or types of the elements are returned byauxiliaryTypes()
.
-
typeInfo
public CommandLine.Model.ITypeInfo typeInfo()
Returns theITypeInfo
that can be used both at compile time (by annotation processors) and at runtime.- Since:
- 4.0
-
userObject
public java.lang.Object userObject()
Returns the user object associated with this option or positional parameters.- Returns:
- may return the annotated program element, or some other useful object
- Since:
- 4.0
-
mapFallbackValue
public java.lang.String mapFallbackValue()
Returns the fallback value for this Map option or positional parameter: the value that is put into the Map when only the key is specified for the option or positional parameter, like-Dkey
instead of-Dkey=value
.If no
mapFallbackValue
is set, key-only Map parameters like-Dkey
are considered invalid user input and cause aCommandLine.ParameterException
to be thrown.By default, this method returns a special "__unspecified__" value indicating that no
mapFallbackValue
was set.- Since:
- 4.6
- See Also:
CommandLine.Option.mapFallbackValue()
,CommandLine.Parameters.mapFallbackValue()
-
defaultValue
public java.lang.String defaultValue()
Returns the default value to assign if this option or positional parameter was not specified on the command line, before splitting and type conversion. This method returns the programmatically set value; this may differ from the default value that is actually used: if this ArgSpec is part of a CommandSpec with aCommandLine.IDefaultValueProvider
, picocli will first try to obtain the default value from the default value provider, and this method is only called if the default provider isnull
or returned anull
value.- Returns:
- the programmatically set default value of this option/positional parameter,
returning
null
means this option or positional parameter does not have a default - See Also:
CommandLine.Model.CommandSpec.defaultValueProvider()
,CommandLine.Model.OptionSpec.fallbackValue()
-
initialValue
public java.lang.Object initialValue()
Returns the initial value of this option or positional parameter: the value that, ifhasInitialValue()
is true, the option will be reset to before parsing (regardless of whether a default value exists), to clear values that would otherwise remain from parsing previous input.
-
hasInitialValue
public boolean hasInitialValue()
Determines whether the option or positional parameter will be reset to theinitialValue()
before parsing new input.
-
showDefaultValue
public CommandLine.Help.Visibility showDefaultValue()
Returns whether this option or positional parameter's default value should be shown in the usage help.
-
defaultValueString
public java.lang.String defaultValueString()
Returns the default value String for the purpose of displaying it in the description, without interpolating variables.- See Also:
defaultValueString(boolean)
-
defaultValueString
public java.lang.String defaultValueString(boolean interpolateVariables)
Returns the default value String displayed in the description; interpolating variables if specified. If this ArgSpec is part of a CommandSpec with aCommandLine.IDefaultValueProvider
, this method will first try to obtain the default value from the default value provider; if the provider isnull
or if it returns anull
value, then next any value set todefaultValue()
is returned, and if this is alsonull
, finally the initial value is returned.- Parameters:
interpolateVariables
- whether to interpolate variables in thedefaultValue
attribute of this ArgSpec- Since:
- 4.0
- See Also:
CommandLine.Model.CommandSpec.defaultValueProvider()
,defaultValue()
-
calcDefaultValue
private java.lang.Object calcDefaultValue(boolean interpolate)
-
defaultValueFromProvider
private java.lang.String defaultValueFromProvider()
-
completionCandidates
public java.lang.Iterable<java.lang.String> completionCandidates()
Returns the explicitly set completion candidates for this option or positional parameter, valid enum constant names, ornull
if this option or positional parameter does not have any completion candidates and its type is not an enum.- Returns:
- the completion candidates for this option or positional parameter, valid enum constant names,
or
null
- Since:
- 3.2
-
parameterConsumer
public CommandLine.IParameterConsumer parameterConsumer()
Returns a customIParameterConsumer
to temporarily suspend picocli's parsing logic and process one or more command line arguments in a custom manner, ornull
. An example of when this may be useful is when passing arguments through to another program.- Since:
- 4.0
-
preprocessor
public CommandLine.IParameterPreprocessor preprocessor()
Returns a customIParameterPreprocessor
to either replace or complement picocli's parsing logic for the parameter(s) of this option or position.- Since:
- 4.6
-
getter
public CommandLine.Model.IGetter getter()
Returns theCommandLine.Model.IGetter
that is responsible for supplying the value of this argument.
-
setter
public CommandLine.Model.ISetter setter()
Returns theCommandLine.Model.ISetter
that is responsible for modifying the value of this argument.
-
scope
public CommandLine.Model.IScope scope()
Returns the bindingCommandLine.Model.IScope
that determines on which object to set the value (or from which object to get the value) of this argument.
-
scopeType
public CommandLine.ScopeType scopeType()
Returns the scope of this argument; it it local, or inherited (it applies to this command as well as all sub- and sub-subcommands).- Returns:
- whether this argument applies to all descendent subcommands of the command where it is defined
- Since:
- 4.3
-
getValue
public <T> T getValue() throws CommandLine.PicocliException
Returns the current value of this argument. Delegates to the currentgetter()
.- Throws:
CommandLine.PicocliException
-
setValue
public <T> T setValue(T newValue) throws CommandLine.PicocliException
Sets the value of this argument to the specified value and returns the previous value. Delegates to the currentsetter()
.- Throws:
CommandLine.PicocliException
-
setValue
@Deprecated public <T> T setValue(T newValue, CommandLine commandLine) throws CommandLine.PicocliException
Deprecated.usesetValue(Object)
instead. This was a design mistake.Sets the value of this argument to the specified value and returns the previous value. Delegates to the currentsetter()
.- Throws:
CommandLine.PicocliException
- Since:
- 3.5
-
isMultiValue
public boolean isMultiValue()
-
isOption
public abstract boolean isOption()
Returnstrue
if this argument is a named option,false
otherwise.
-
isPositional
public abstract boolean isPositional()
Returnstrue
if this argument is a positional parameter,false
otherwise.
-
group
public CommandLine.Model.ArgGroupSpec group()
Returns the groups this option or positional parameter belongs to, ornull
if this option is not part of a group.- Since:
- 4.0
-
command
public CommandLine.Model.CommandSpec command()
Returns the command this option or positional parameter belongs to.Beware that it is possible to programmatically add an option or positional parameter to more than one command model. (This will not happen in models that are auto-generated from annotations). In that case this method will only return the one it was added to last.
If the option or positional parameter has not yet been attached to a command,
null
will be returned.- Since:
- 4.1
-
stringValues
public java.util.List<java.lang.String> stringValues()
Returns the untyped command line arguments matched by this option or positional parameter spec.- Returns:
- the matched arguments after splitting, but before type conversion.
For map properties,
"key=value"
values are split into the key and the value part.
-
typedValues
public java.util.List<java.lang.Object> typedValues()
Returns the typed command line arguments matched by this option or positional parameter spec.- Returns:
- the matched arguments after splitting and type conversion.
For map properties,
"key=value"
values are split into the key and the value part.
-
resetStringValues
protected void resetStringValues()
Sets thestringValues
to a new list instance.
-
originalStringValues
public java.util.List<java.lang.String> originalStringValues()
Returns the original command line arguments matched by this option or positional parameter spec.- Returns:
- the matched arguments as found on the command line: empty Strings for options without value, the
values have not been split, and for map properties values may look like
"key=value"
-
resetOriginalStringValues
protected void resetOriginalStringValues()
Sets theoriginalStringValues
to a new list instance.
-
internalShowDefaultValue
protected boolean internalShowDefaultValue(boolean usageHelpShowDefaults)
Returns whether the default for this option or positional parameter should be shown, potentially overriding the specified global setting.- Parameters:
usageHelpShowDefaults
- whether the command's UsageMessageSpec is configured to show default values.
-
messages
public CommandLine.Model.Messages messages()
Returns the Messages for this arg specification, ornull
.- Since:
- 3.6
-
messages
public CommandLine.Model.ArgSpec messages(CommandLine.Model.Messages msgs)
Sets the Messages for this ArgSpec, and returns this ArgSpec.- Parameters:
msgs
- the new Messages value, may benull
- Since:
- 3.6
- See Also:
CommandLine.Command.resourceBundle()
,description()
,description()
-
toString
public java.lang.String toString()
Returns a string respresentation of this option or positional parameter.- Overrides:
toString
in classjava.lang.Object
-
scopeString
private java.lang.String scopeString()
-
splitValue
java.lang.String[] splitValue(java.lang.String value, CommandLine.Model.ParserSpec parser, CommandLine.Range arity, int consumed)
-
debug
private java.lang.String[] debug(java.lang.String[] result, java.lang.String msg, java.lang.String value)
-
splitRespectingQuotedStrings
private static java.lang.String[] splitRespectingQuotedStrings(java.lang.String value, int limit, CommandLine.Model.ParserSpec parser, CommandLine.Model.ArgSpec argSpec, java.lang.String splitRegex)
-
restoreQuotedValues
private static java.lang.String restoreQuotedValues(java.lang.String part, java.util.Queue<java.lang.String> quotedValues, CommandLine.Model.ParserSpec parser)
-
equalsImpl
protected boolean equalsImpl(CommandLine.Model.ArgSpec other)
-
hashCodeImpl
protected int hashCodeImpl()
-
describeTypes
private static java.lang.String describeTypes(java.util.Collection<CommandLine.Model.ArgSpec> args)
-
describe
private static java.lang.String describe(java.util.Collection<CommandLine.Model.ArgSpec> args)
-
describe
private static java.lang.String describe(java.util.Collection<CommandLine.Model.ArgSpec> args, java.lang.String separator, java.lang.String optionParamSeparator, java.lang.String openingQuote, java.lang.String closingQuote)
-
describe
private static java.lang.String describe(CommandLine.Model.ArgSpec argSpec, java.lang.String separator)
Returns a description of the option or positional arg, e.g.-a=<a>
- Parameters:
separator
- separator between arg and arg parameter label, usually '='
-
describe
private static java.lang.String describe(CommandLine.Model.ArgSpec argSpec, java.lang.String separator, java.lang.String value)
Returns a description of the option or positional arg- Parameters:
separator
- separator between arg and arg parameter value, usually '='value
- the value to append after the separator
-
interpolate
java.lang.String interpolate(java.lang.String value)
-
interpolate
java.lang.String[] interpolate(java.lang.String[] values)
-
-