Package nz.org.riskscape.picocli
Class CommandLine.Model.PositionalParamSpec.Builder
java.lang.Object
nz.org.riskscape.picocli.CommandLine.Model.PositionalParamSpec.Builder
- Enclosing class:
- CommandLine.Model.PositionalParamSpec
Builder responsible for creating valid
PositionalParamSpec
objects.- Since:
- 3.0
-
Method Summary
Modifier and TypeMethodDescriptionarity()
Returns how many arguments this option or positional parameter requires.Sets how many arguments this option or positional parameter requires, and returns this builder.arity
(CommandLine.Range arity) Sets how many arguments this option or positional parameter requires, and returns this builder.Class<?>[]
Returns auxiliary type information used when thetype()
is a genericCollection
,Map
or an abstract class.auxiliaryTypes
(Class<?>... types) Sets auxiliary type information, and returns this builder.build()
Returns a validPositionalParamSpec
instance.Returns the completion candidates for this option or positional parameter, ornull
.completionCandidates
(Iterable<String> completionCandidates) Sets the completion candidates for this option or positional parameter, and returns this builder.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).converters
(CommandLine.ITypeConverter<?>... cs) Sets option/positional param-specific converter (or converters for Maps), and returns this builder.Returns the default value of this option or positional parameter, before splitting and type conversion.defaultValue
(String defaultValue) Sets the default value of this option or positional parameter to the specified value, and returns this builder.String[]
Returns the description of this option, used when generating the usage documentation.description
(String... description) Sets the description of this option, used when generating the usage documentation, and returns this builder.Returns the description key of this arg spec, used to get the description from a resource bundle.descriptionKey
(String descriptionKey) Sets the description key that is used to look up the description in a resource bundle, and returns this builder.getter()
Returns theCommandLine.Model.IGetter
that is responsible for supplying the value of this argument.getter
(CommandLine.Model.IGetter getter) Sets theCommandLine.Model.IGetter
that is responsible for getting the value of this argument, and returns this builder.boolean
Determines whether the option or positional parameter will be reset to theinitialValue()
before parsing new input.hasInitialValue
(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.hidden
(boolean hidden) Sets whether this option should be excluded from the usage message, and returns this builder.boolean
Returns whether usage syntax decorations around the paramLabel should be suppressed.hideParamSyntax
(boolean hideParamSyntax) Sets whether usage syntax decorations around the paramLabel should be suppressed.index()
Returns an index or range specifying which of the command line arguments should be assigned to this positional parameter.Sets the index or range specifying which of the command line arguments should be assigned to this positional parameter, and returns this builder.index
(CommandLine.Range index) Sets the index or range specifying which of the command line arguments should be assigned to this positional parameter, and returns this builder.Returns the initial value this option or positional parameter.initialValue
(Object initialValue) Sets the initial value of this option or positional parameter to the specified value, and returns this builder.boolean
Returns whether this option prompts the user to enter a value on the command line.interactive
(boolean interactive) Sets whether this option prompts the user to enter a value on the command line, and returns this builder.Returns the custom parameter handler for this option or positional parameter, ornull
.parameterConsumer
(CommandLine.IParameterConsumer parameterConsumer) Sets the parameterConsumer for this option or positional parameter, and returns this builder.Returns the name of the option or positional parameter used in the usage help message.paramLabel
(String paramLabel) Sets the name of the option or positional parameter used in the usage help message, and returns this builder.boolean
required()
Returns whether this is a required option or positional parameter.required
(boolean required) Sets whether this is a required option or positional parameter, and returns this builder.scope()
Returns theCommandLine.Model.IScope
that determines where the setter sets the value (or the getter gets the value) of this argument.scope
(CommandLine.Model.IScope scope) Sets theCommandLine.Model.IScope
that targets where the setter sets the value, and returns this builder.self()
Returns this builder.setter()
Returns theCommandLine.Model.ISetter
that is responsible for modifying the value of this argument.setter
(CommandLine.Model.ISetter setter) Sets theCommandLine.Model.ISetter
that is responsible for modifying the value of this argument, and returns this builder.Returns whether this option or positional parameter's default value should be shown in the usage help.showDefaultValue
(CommandLine.Help.Visibility visibility) Sets whether this option or positional parameter's default value should be shown in the usage help, and returns this builder.Returns a regular expression to split option parameter values or""
if the value should not be split.splitRegex
(String splitRegex) Sets a regular expression to split option parameter values or""
if the value should not be split, and returns this builder.toString()
Class<?>
type()
Returns the type to convert the option or positional parameter to before setting the value.Sets the type to convert the option or positional parameter to before setting the value, and returns this builder.typeInfo()
Returns the type info for this option or positional parameter.typeInfo
(CommandLine.Model.ITypeInfo typeInfo) Sets the type info for this option or positional parameter, and returns this builder.Returns the user object associated with this option or positional parameters.userObject
(Object userObject) Sets the user object associated with this option or positional parameters, and returns this builder.withToString
(String toString) Sets the string respresentation of this option or positional parameter to the specified value, and returns this builder.
-
Method Details
-
build
Returns a validPositionalParamSpec
instance. -
self
Returns this builder. -
index
Returns an index or range specifying which of the command line arguments should be assigned to this positional parameter.- See Also:
-
index
Sets the index or range specifying which of the command line arguments should be assigned to this positional parameter, and returns this builder. -
index
Sets the index or range specifying which of the command line arguments should be assigned to this positional parameter, and returns this builder. -
required
public boolean required()Returns whether this is a required option or positional parameter.- See Also:
-
interactive
public boolean interactive()Returns whether this option prompts the user to enter a value on the command line.- See Also:
-
description
Returns the description of this option, used when generating the usage documentation.- See Also:
-
descriptionKey
Returns the description key of this arg spec, used to get the description from a resource bundle.- Since:
- 3.6
- See Also:
-
arity
Returns how many arguments this option or positional parameter requires.- See Also:
-
paramLabel
Returns the name of the option or positional parameter used in the usage help message.- See Also:
-
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
Returns auxiliary type information used when thetype()
is a genericCollection
,Map
or an abstract class.- See Also:
-
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:
-
splitRegex
Returns a regular expression to split option parameter values or""
if the value should not be split.- See Also:
-
type
Returns the type to convert the option or positional parameter to before setting the value. -
typeInfo
Returns the type info for this option or positional parameter.- Returns:
- type information that does not require
Class
objects and be constructed both at runtime and compile time - Since:
- 4.0
-
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
-
defaultValue
Returns the default value of this option or positional parameter, before splitting and type conversion. A value ofnull
means this option or positional parameter does not have a default. -
initialValue
Returns the initial value this option or positional parameter. IfhasInitialValue()
is true, the option will be reset to the initial value 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
Returns whether this option or positional parameter's default value should be shown in the usage help. -
completionCandidates
Returns the completion candidates for this option or positional parameter, ornull
.- Since:
- 3.2
-
parameterConsumer
Returns the custom parameter handler for this option or positional parameter, ornull
.- Since:
- 4.0
-
getter
Returns theCommandLine.Model.IGetter
that is responsible for supplying the value of this argument. -
setter
Returns theCommandLine.Model.ISetter
that is responsible for modifying the value of this argument. -
scope
Returns theCommandLine.Model.IScope
that determines where the setter sets the value (or the getter gets the value) of this argument. -
toString
-
required
Sets whether this is a required option or positional parameter, and returns this builder. -
interactive
Sets whether this option prompts the user to enter a value on the command line, and returns this builder. -
description
Sets the description of this option, used when generating the usage documentation, and returns this builder.- See Also:
-
descriptionKey
Sets the description key that is used to look up the description in a resource bundle, and returns this builder.- Since:
- 3.6
- See Also:
-
arity
Sets how many arguments this option or positional parameter requires, and returns this builder. -
arity
Sets how many arguments this option or positional parameter requires, and returns this builder. -
paramLabel
Sets the name of the option or positional parameter used in the usage help message, and returns this builder. -
hideParamSyntax
Sets 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
Sets auxiliary type information, and returns this builder. -
converters
public CommandLine.Model.PositionalParamSpec.Builder converters(CommandLine.ITypeConverter<?>... cs) Sets option/positional param-specific converter (or converters for Maps), and returns this builder. -
splitRegex
Sets a regular expression to split option parameter values or""
if the value should not be split, and returns this builder. -
showDefaultValue
public CommandLine.Model.PositionalParamSpec.Builder showDefaultValue(CommandLine.Help.Visibility visibility) Sets whether this option or positional parameter's default value should be shown in the usage help, and returns this builder. -
completionCandidates
public CommandLine.Model.PositionalParamSpec.Builder completionCandidates(Iterable<String> completionCandidates) Sets the completion candidates for this option or positional parameter, and returns this builder.- Since:
- 3.2
-
parameterConsumer
public CommandLine.Model.PositionalParamSpec.Builder parameterConsumer(CommandLine.IParameterConsumer parameterConsumer) Sets the parameterConsumer for this option or positional parameter, and returns this builder.- Since:
- 4.0
-
type
Sets the type to convert the option or positional parameter to before setting the value, and returns this builder.- Parameters:
propertyType
- the type of this option or parameter. For multi-value options and positional parameters this can be an array, or a (sub-type of) Collection or Map.
-
typeInfo
Sets the type info for this option or positional parameter, and returns this builder.- Parameters:
typeInfo
- type information that does not requireClass
objects and be constructed both at runtime and compile time- Since:
- 4.0
-
userObject
Sets the user object associated with this option or positional parameters, and returns this builder.- Parameters:
userObject
- may be the annotated program element, or some other useful object- Since:
- 4.0
-
defaultValue
Sets the default value of this option or positional parameter to the specified value, and returns this builder. Before parsing the command line, the result of splitting and type converting this default value is applied to the option or positional parameter. A value ofnull
or"__no_default_value__"
means no default. -
initialValue
Sets the initial value of this option or positional parameter to the specified value, and returns this builder. IfhasInitialValue()
is true, the option will be reset to the initial value before parsing (regardless of whether a default value exists), to clear values that would otherwise remain from parsing previous input. -
hasInitialValue
Determines whether the option or positional parameter will be reset to theinitialValue()
before parsing new input. -
getter
Sets theCommandLine.Model.IGetter
that is responsible for getting the value of this argument, and returns this builder. -
setter
Sets theCommandLine.Model.ISetter
that is responsible for modifying the value of this argument, and returns this builder. -
scope
Sets theCommandLine.Model.IScope
that targets where the setter sets the value, and returns this builder. -
withToString
Sets the string respresentation of this option or positional parameter to the specified value, and returns this builder.
-