public static class CommandLine.Model.CommandSpec extends Object
CommandSpec
class models a command specification, including the options, positional parameters and subcommands
supported by the command, as well as attributes for the version help message and the usage help message of the command.
Picocli views a command line application as a hierarchy of commands: there is a top-level command (usually the Java
class with the main
method) with optionally a set of command line options, positional parameters and subcommands.
Subcommands themselves can have options, positional parameters and nested sub-subcommands to any level of depth.
The object model has a corresponding hierarchy of CommandSpec
objects, each with a set of CommandLine.Model.OptionSpec
,
CommandLine.Model.PositionalParamSpec
and subcommands associated with it.
This object model is used by the picocli command line interpreter and help message generator.
Picocli can construct a CommandSpec
automatically from classes with @Command
, @Option
and
@Parameters
annotations. Alternatively a CommandSpec
can be constructed programmatically.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_COMMAND_NAME
Constant String holding the default program name:
"<main class>" . |
Modifier and Type | Method and Description |
---|---|
CommandLine.Model.CommandSpec |
add(CommandLine.Model.ArgSpec arg)
Adds the specified option spec or positional parameter spec to the list of configured arguments to expect.
|
CommandLine.Model.CommandSpec |
addArgGroup(CommandLine.Model.ArgGroupSpec group)
Adds the specified argument group to the groups in this command.
|
CommandLine.Model.CommandSpec |
addMethodSubcommands()
Reflects on the class of the user object and registers any command methods
(class methods annotated with
@Command ) as subcommands. |
CommandLine.Model.CommandSpec |
addMethodSubcommands(CommandLine.IFactory factory)
Reflects on the class of the user object and registers any command methods
(class methods annotated with
@Command ) as subcommands. |
CommandLine.Model.CommandSpec |
addMixin(String name,
CommandLine.Model.CommandSpec mixin)
Adds the specified mixin
CommandSpec object to the map of mixins for this command. |
CommandLine.Model.CommandSpec |
addMixin(String name,
CommandLine.Model.CommandSpec mixin,
CommandLine.Model.IAnnotatedElement annotatedElement)
Adds the specified mixin
CommandSpec object to the map of mixins for this command. |
CommandLine.Model.CommandSpec |
addOption(CommandLine.Model.OptionSpec option)
Adds the specified option spec to the list of configured arguments to expect.
|
CommandLine.Model.CommandSpec |
addParentCommandElement(CommandLine.Model.IAnnotatedElement spec)
Adds the specified
{@literal @}ParentCommand -annotated program element to the list of elements for this command. |
CommandLine.Model.CommandSpec |
addPositional(CommandLine.Model.PositionalParamSpec positional)
Adds the specified positional parameter spec to the list of configured arguments to expect.
|
CommandLine.Model.CommandSpec |
addSpecElement(CommandLine.Model.IAnnotatedElement spec)
Adds the specified
{@literal @}Spec -annotated program element to the list of elements for this command. |
CommandLine.Model.CommandSpec |
addSubcommand(String name,
CommandLine.Model.CommandSpec subcommand)
Adds the specified subcommand with the specified name.
|
CommandLine.Model.CommandSpec |
addSubcommand(String name,
CommandLine subCommandLine)
Adds the specified subcommand with the specified name.
|
CommandLine.Model.CommandSpec |
addUnmatchedArgsBinding(CommandLine.Model.UnmatchedArgsBinding spec)
Adds the specified
UnmatchedArgsBinding to the list of model objects to capture unmatched arguments for this command. |
String[] |
aliases()
Returns the alias command names of this subcommand.
|
CommandLine.Model.CommandSpec |
aliases(String... aliases)
Sets the alternative names by which this subcommand is recognized on the command line.
|
List<CommandLine.Model.ArgGroupSpec> |
argGroups()
Returns the argument groups in this command.
|
List<CommandLine.Model.ArgSpec> |
args()
Returns the list of all options and positional parameters configured for this command.
|
CommandLine |
commandLine()
Returns the CommandLine constructed with this
CommandSpec model. |
protected CommandLine.Model.CommandSpec |
commandLine(CommandLine commandLine)
Sets the CommandLine constructed with this
CommandSpec model. |
static CommandLine.Model.CommandSpec |
create()
Creates and returns a new
CommandSpec without any associated user object. |
CommandLine.IDefaultValueProvider |
defaultValueProvider()
Returns the default value provider for this command.
|
CommandLine.Model.CommandSpec |
defaultValueProvider(CommandLine.IDefaultValueProvider defaultValueProvider)
Sets default value provider for this command.
|
int |
exitCodeOnExecutionException()
Returns exit code signifying that an exception occurred when invoking the Runnable, Callable or Method user object of a command.
|
CommandLine.Model.CommandSpec |
exitCodeOnExecutionException(int newValue)
Sets exit code signifying that an exception occurred when invoking the Runnable, Callable or Method user object of a command.
|
int |
exitCodeOnInvalidInput()
Returns exit code for command line usage error.
|
CommandLine.Model.CommandSpec |
exitCodeOnInvalidInput(int newValue)
Sets exit code for command line usage error.
|
int |
exitCodeOnSuccess()
Returns exit code for successful termination.
|
CommandLine.Model.CommandSpec |
exitCodeOnSuccess(int newValue)
Sets exit code for successful termination.
|
int |
exitCodeOnUsageHelp()
Returns exit code for successful termination after printing usage help on user request.
|
CommandLine.Model.CommandSpec |
exitCodeOnUsageHelp(int newValue)
Sets exit code for successful termination after printing usage help on user request.
|
int |
exitCodeOnVersionHelp()
Returns exit code for successful termination after printing version help on user request.
|
CommandLine.Model.CommandSpec |
exitCodeOnVersionHelp(int newValue)
Sets exit code for successful termination after printing version help on user request.
|
CommandLine.Model.OptionSpec |
findOption(char shortName)
Returns the option with the specified short name, or
null if no option with that name is defined for this command. |
CommandLine.Model.OptionSpec |
findOption(String name)
Returns the option with the specified name, or
null if no option with that name is defined for this command. |
static CommandLine.Model.CommandSpec |
forAnnotatedObject(Object userObject)
Creates and returns a new
CommandSpec initialized from the specified associated user object. |
static CommandLine.Model.CommandSpec |
forAnnotatedObject(Object userObject,
CommandLine.IFactory factory)
Creates and returns a new
CommandSpec initialized from the specified associated user object. |
static CommandLine.Model.CommandSpec |
forAnnotatedObjectLenient(Object userObject)
Creates and returns a new
CommandSpec initialized from the specified associated user object. |
static CommandLine.Model.CommandSpec |
forAnnotatedObjectLenient(Object userObject,
CommandLine.IFactory factory)
Creates and returns a new
CommandSpec initialized from the specified associated user object. |
boolean |
helpCommand()
Returns whether this subcommand is a help command, and required options and positional
parameters of the parent command should not be validated.
|
CommandLine.Model.CommandSpec |
helpCommand(boolean newValue)
Sets whether this is a help command and required parameter checking should be suspended.
|
boolean |
inherited()
Returns whether this command is inherited from a parent command.
|
boolean |
interpolateVariables()
Returns whether variables should be interpolated in String values.
|
CommandLine.Model.CommandSpec |
interpolateVariables(Boolean interpolate)
Sets whether variables should be interpolated in String values.
|
boolean |
isAddMethodSubcommands()
Returns whether method commands should be added as subcommands.
|
Map<String,CommandLine.Model.IAnnotatedElement> |
mixinAnnotatedElements()
Returns a map of the mixin names to mixin
IAnnotatedElement objects for this command. |
Map<String,CommandLine.Model.CommandSpec> |
mixins()
Returns a map of the mixin names to mixin
CommandSpec objects configured for this command. |
boolean |
mixinStandardHelpOptions()
Returns
true if the standard help options have been mixed in with this command, false otherwise. |
CommandLine.Model.CommandSpec |
mixinStandardHelpOptions(boolean newValue)
Sets whether the standard help options should be mixed in with this command.
|
CommandLine.IModelTransformer |
modelTransformer()
Returns the model transformer for this CommandSpec instance.
|
CommandLine.Model.CommandSpec |
modelTransformer(CommandLine.IModelTransformer modelTransformer)
Sets the model transformer for this CommandSpec instance.
|
String |
name()
Returns name of this command.
|
CommandLine.Model.CommandSpec |
name(String name)
Sets the String to use as the program name in the synopsis line of the help message.
|
Set<String> |
names()
|
CommandLine.INegatableOptionTransformer |
negatableOptionTransformer()
Returns the
INegatableOptionTransformer used to create the negative form of negatable options. |
CommandLine.Model.CommandSpec |
negatableOptionTransformer(CommandLine.INegatableOptionTransformer newValue)
Sets the
INegatableOptionTransformer used to create the negative form of negatable options. |
Map<String,CommandLine.Model.OptionSpec> |
negatedOptionsMap()
Returns a map of the negated option names to option spec objects configured for this command.
|
List<CommandLine.Model.OptionSpec> |
options()
Returns the list of options configured for this command.
|
boolean |
optionsCaseInsensitive()
Returns whether the options are case-insensitive.
|
CommandLine.Model.CommandSpec |
optionsCaseInsensitive(boolean caseInsensitiveOptions)
Sets the case-insensitivity of options.
|
Map<String,CommandLine.Model.OptionSpec> |
optionsMap()
Returns a map of the option names to option spec objects configured for this command.
|
CommandLine.Model.CommandSpec |
parent()
Returns the parent command of this subcommand, or
null if this is a top-level command. |
CommandLine.Model.CommandSpec |
parent(CommandLine.Model.CommandSpec parent)
Sets the parent command of this subcommand.
|
List<CommandLine.Model.IAnnotatedElement> |
parentCommandElements()
Returns the list of program elements annotated with
{@literal @}ParentCommand configured for this command. |
CommandLine.Model.ParserSpec |
parser()
Returns the parser specification for this command.
|
CommandLine.Model.CommandSpec |
parser(CommandLine.Model.ParserSpec settings)
Initializes the parser specification for this command from the specified settings and returns this commandSpec.
|
List<CommandLine.Model.PositionalParamSpec> |
positionalParameters()
Returns the list of positional parameters configured for this command.
|
Map<Character,CommandLine.Model.OptionSpec> |
posixOptionsMap()
Returns a map of the short (single character) option names to option spec objects configured for this command.
|
CommandLine.IParameterPreprocessor |
preprocessor()
Returns the preprocessor for this CommandSpec instance.
|
CommandLine.Model.CommandSpec |
preprocessor(CommandLine.IParameterPreprocessor preprocessor)
Sets the preprocessor for this CommandSpec instance.
|
String |
qualifiedName()
Returns the String to use as the program name in the synopsis line of the help message:
this command's
name , preceded by the qualified name of the parent command, if any, separated by a space. |
String |
qualifiedName(String separator)
Returns this command's fully qualified name, which is its
name , preceded by the qualified name of the parent command, if this command has a parent command. |
CommandLine.Model.CommandSpec |
remove(CommandLine.Model.ArgSpec arg)
(INCUBATING) Removes the specified option spec or positional parameter spec from the list of configured arguments to expect.
|
CommandLine |
removeSubcommand(String name)
Removes the subcommand with the specified name or alias from this CommandSpec and
returns the
CommandLine instance that was associated with the specified name,
or null of the specified name was not associated with a subcommand. |
List<CommandLine.Model.ArgSpec> |
requiredArgs()
Returns the list of required options and positional parameters configured for this command.
|
ResourceBundle |
resourceBundle()
Returns the resource bundle for this command.
|
CommandLine.Model.CommandSpec |
resourceBundle(ResourceBundle bundle)
Initializes the resource bundle for this command: sets the
UsageMessageSpec.messages to
a Messages object created from this command spec and the specified bundle, and then sets the
ArgSpec.messages of all options and positional parameters in this command
to the same Messages instance. |
String |
resourceBundleBaseName()
Returns the resource bundle base name for this command.
|
CommandLine.Model.CommandSpec |
resourceBundleBaseName(String resourceBundleBaseName)
Initializes the resource bundle for this command: sets the
UsageMessageSpec.messages to
a Messages object created from this command spec and the specified bundle, and then sets the
ArgSpec.messages of all options and positional parameters in this command
to the same Messages instance. |
CommandLine.Model.CommandSpec |
root()
Returns the root command: the top-level command of the hierarchy, never
null . |
CommandLine.ScopeType |
scopeType()
Returns the scope of this argument; is it local, or inherited (it applies to this command as well as all sub- and sub-subcommands).
|
CommandLine.Model.CommandSpec |
scopeType(CommandLine.ScopeType scopeType)
Sets the scope of where this argument applies: only this command, or also all sub (and sub-sub) commands, and returns this builder.
|
CommandLine.Model.CommandSpec |
setAddMethodSubcommands(Boolean addMethodSubcommands)
Sets whether method commands should be added as subcommands.
|
List<CommandLine.Model.IAnnotatedElement> |
specElements()
Returns the list of program elements annotated with
{@literal @}Spec configured for this command. |
Map<String,CommandLine> |
subcommands()
Returns a read-only view of the subcommand map.
|
boolean |
subcommandsCaseInsensitive()
Returns whether the subcommands are case-insensitive.
|
CommandLine.Model.CommandSpec |
subcommandsCaseInsensitive(boolean caseInsensitiveSubcommands)
Sets the case-insensitivity of subcommands.
|
boolean |
subcommandsRepeatable()
Returns whether the subcommands of this command are repeatable, that is, whether such subcommands can
occur multiple times and may be followed by sibling commands instead of just child commands.
|
CommandLine.Model.CommandSpec |
subcommandsRepeatable(boolean subcommandsRepeatable)
Sets whether the subcommands of this command are repeatable, that is, whether such subcommands can
occur multiple times and may be followed by sibling commands instead of just child commands.
|
String |
toString()
Returns a string representation of this command, used in error messages and trace messages.
|
List<CommandLine.Model.UnmatchedArgsBinding> |
unmatchedArgsBindings()
Returns the list of
UnmatchedArgumentsBindings configured for this command;
each UnmatchedArgsBinding captures the arguments that could not be matched to any options or positional parameters. |
void |
updateCommandAttributes(CommandLine.Command cmd,
CommandLine.IFactory factory)
Updates the following attributes from the specified
@Command annotation:
aliases, parser separator , command name, version, help command,
version provider, default provider and usage message spec . |
CommandLine.Model.UsageMessageSpec |
usageMessage()
Returns the usage help message specification for this command.
|
CommandLine.Model.CommandSpec |
usageMessage(CommandLine.Model.UsageMessageSpec settings)
Initializes the usageMessage specification for this command from the specified settings and returns this commandSpec.
|
Object |
userObject()
Returns the user object associated with this command.
|
String[] |
version()
Returns version information for this command, to print to the console when the user specifies an
option to request version help.
|
CommandLine.Model.CommandSpec |
version(String... version)
Sets version information literals for this command, to print to the console when the user specifies an
option to request version help.
|
CommandLine.IVersionProvider |
versionProvider()
Returns the version provider for this command, to generate the
version() strings. |
CommandLine.Model.CommandSpec |
versionProvider(CommandLine.IVersionProvider versionProvider)
Sets version provider for this command, to generate the
version() strings. |
CommandLine.Model.CommandSpec |
withToString(String newValue)
Sets the string representation of this command, used in error messages and trace messages.
|
static CommandLine.Model.CommandSpec |
wrapWithoutInspection(Object userObject)
Creates and returns a new
CommandSpec with the specified associated user object. |
static CommandLine.Model.CommandSpec |
wrapWithoutInspection(Object userObject,
CommandLine.IFactory factory)
Creates and returns a new
CommandSpec with the specified associated user object. |
public static final String DEFAULT_COMMAND_NAME
"<main class>"
.public static CommandLine.Model.CommandSpec create()
CommandSpec
without any associated user object.public static CommandLine.Model.CommandSpec wrapWithoutInspection(Object userObject)
CommandSpec
with the specified associated user object.
The specified user object is not inspected for annotations.userObject
- the associated user object. May be any object, may be null
.public static CommandLine.Model.CommandSpec wrapWithoutInspection(Object userObject, CommandLine.IFactory factory)
CommandSpec
with the specified associated user object.
The specified user object is not inspected for annotations.userObject
- the associated user object. May be any object, may be null
.factory
- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributespublic static CommandLine.Model.CommandSpec forAnnotatedObject(Object userObject)
CommandSpec
initialized from the specified associated user object. The specified
user object must have at least one CommandLine.Command
, CommandLine.Option
or CommandLine.Parameters
annotation.userObject
- the user object annotated with CommandLine.Command
, CommandLine.Option
and/or CommandLine.Parameters
annotations.CommandLine.InitializationException
- if the specified object has no picocli annotations or has invalid annotationspublic static CommandLine.Model.CommandSpec forAnnotatedObject(Object userObject, CommandLine.IFactory factory)
CommandSpec
initialized from the specified associated user object. The specified
user object must have at least one CommandLine.Command
, CommandLine.Option
or CommandLine.Parameters
annotation.userObject
- the user object annotated with CommandLine.Command
, CommandLine.Option
and/or CommandLine.Parameters
annotations.factory
- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributesCommandLine.InitializationException
- if the specified object has no picocli annotations or has invalid annotationspublic static CommandLine.Model.CommandSpec forAnnotatedObjectLenient(Object userObject)
CommandSpec
initialized from the specified associated user object. If the specified
user object has no CommandLine.Command
, CommandLine.Option
or CommandLine.Parameters
annotations, an empty CommandSpec
is returned.userObject
- the user object annotated with CommandLine.Command
, CommandLine.Option
and/or CommandLine.Parameters
annotations.CommandLine.InitializationException
- if the specified object has invalid annotationspublic static CommandLine.Model.CommandSpec forAnnotatedObjectLenient(Object userObject, CommandLine.IFactory factory)
CommandSpec
initialized from the specified associated user object. If the specified
user object has no CommandLine.Command
, CommandLine.Option
or CommandLine.Parameters
annotations, an empty CommandSpec
is returned.userObject
- the user object annotated with CommandLine.Command
, CommandLine.Option
and/or CommandLine.Parameters
annotations.factory
- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributesCommandLine.InitializationException
- if the specified object has invalid annotationspublic Object userObject()
CommandLine.getCommand()
public CommandLine commandLine()
CommandSpec
model.protected CommandLine.Model.CommandSpec commandLine(CommandLine commandLine)
CommandSpec
model.public CommandLine.Model.ParserSpec parser()
public CommandLine.Model.CommandSpec parser(CommandLine.Model.ParserSpec settings)
public CommandLine.Model.UsageMessageSpec usageMessage()
public CommandLine.Model.CommandSpec usageMessage(CommandLine.Model.UsageMessageSpec settings)
public boolean subcommandsCaseInsensitive()
public CommandLine.Model.CommandSpec subcommandsCaseInsensitive(boolean caseInsensitiveSubcommands)
public boolean optionsCaseInsensitive()
public CommandLine.Model.CommandSpec optionsCaseInsensitive(boolean caseInsensitiveOptions)
CommandLine.INegatableOptionTransformer
that was previously installed will be replaced by the case-insensitive
version of the default transformer. To ensure your custom transformer is used, install it last, after changing case sensitivity.public String resourceBundleBaseName()
public CommandLine.Model.CommandSpec resourceBundleBaseName(String resourceBundleBaseName)
UsageMessageSpec.messages
to
a Messages
object created from this command spec and the specified bundle, and then sets the
ArgSpec.messages
of all options and positional parameters in this command
to the same Messages
instance. Subcommands are not modified.
This method is preferable to resourceBundle(ResourceBundle)
for pre-Java 8
resourceBundleBaseName
- the base name of the ResourceBundle to set, may be null
addSubcommand(String, CommandLine)
public ResourceBundle resourceBundle()
public CommandLine.Model.CommandSpec resourceBundle(ResourceBundle bundle)
UsageMessageSpec.messages
to
a Messages
object created from this command spec and the specified bundle, and then sets the
ArgSpec.messages
of all options and positional parameters in this command
to the same Messages
instance. Subcommands are not modified.bundle
- the ResourceBundle to set, may be null
addSubcommand(String, CommandLine)
public Map<String,CommandLine> subcommands()
public CommandLine.Model.CommandSpec addSubcommand(String name, CommandLine.Model.CommandSpec subcommand)
name
- subcommand name - the preferred subcommand name to register the subcommand under.
If null
, the name of the specified subcommand is used;
if this is also null
, the first alias is used.
When this String is encountered in the command line arguments, the subcommand is invoked.subcommand
- describes the subcommand to envoke when the name is encountered on the command lineCommandSpec
object for method chainingCommandLine.InitializationException
- if the specified name is null
, and no alternative name could be found,
or if another subcommand was already registered under the same name, or if one of the aliases
of the specified subcommand was already used by another subcommand.public CommandLine.Model.CommandSpec addSubcommand(String name, CommandLine subCommandLine)
name
- subcommand name - the preferred subcommand name to register the subcommand under.
If null
, the name of the specified subcommand is used;
if this is also null
, the first alias is used.
When this String is encountered in the command line arguments, the subcommand is invoked.subCommandLine
- the subcommand to envoke when the name is encountered on the command lineCommandSpec
object for method chainingCommandLine.InitializationException
- if the specified name is null
, and no alternative name could be found,
or if another subcommand was already registered under the same name, or if one of the aliases
of the specified subcommand was already used by another subcommand.public CommandLine removeSubcommand(String name)
CommandLine
instance that was associated with the specified name,
or null
of the specified name was not associated with a subcommand.name
- name or alias of the subcommand to remove; may be
abbreviated
or case-insensitive
CommandLine
instance or null
public boolean isAddMethodSubcommands()
public CommandLine.Model.CommandSpec setAddMethodSubcommands(Boolean addMethodSubcommands)
public boolean interpolateVariables()
public CommandLine.Model.CommandSpec interpolateVariables(Boolean interpolate)
public CommandLine.Model.CommandSpec addMethodSubcommands()
@Command
) as subcommands.CommandLine.Model.CommandSpec
object for method chainingaddMethodSubcommands(CommandLine.IFactory)
,
addSubcommand(String, CommandLine)
public CommandLine.Model.CommandSpec addMethodSubcommands(CommandLine.IFactory factory)
@Command
) as subcommands.factory
- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributesCommandLine.Model.CommandSpec
object for method chainingaddSubcommand(String, CommandLine)
public CommandLine.Model.CommandSpec parent()
null
if this is a top-level command.public CommandLine.Model.CommandSpec root()
null
.public CommandLine.Model.CommandSpec parent(CommandLine.Model.CommandSpec parent)
public CommandLine.Model.CommandSpec add(CommandLine.Model.ArgSpec arg)
arg
- the option spec or positional parameter spec to addpublic CommandLine.Model.CommandSpec addOption(CommandLine.Model.OptionSpec option)
defaultValueProvider()
IDefaultValueProvider}.option
- the option spec to addCommandLine.DuplicateOptionAnnotationsException
- if any of the names of the specified option is the same as the name of another optionpublic CommandLine.Model.CommandSpec addPositional(CommandLine.Model.PositionalParamSpec positional)
defaultValueProvider()
IDefaultValueProvider}.positional
- the positional parameter spec to addpublic CommandLine.Model.CommandSpec remove(CommandLine.Model.ArgSpec arg)
arg
- the option spec or positional parameter spec to removeUnsupportedOperationException
- if the specified ArgSpec is part of a CommandLine.Model.ArgGroupSpec
NoSuchElementException
- if the specified ArgSpec is not part of this CommandSpec
public CommandLine.Model.CommandSpec addArgGroup(CommandLine.Model.ArgGroupSpec group)
group
- the group spec to addCommandLine.InitializationException
- if the specified group or one of its ancestors has already been addedpublic CommandLine.Model.CommandSpec addMixin(String name, CommandLine.Model.CommandSpec mixin, CommandLine.Model.IAnnotatedElement annotatedElement)
CommandSpec
object to the map of mixins for this command.name
- the name that can be used to later retrieve the mixinmixin
- the mixin whose options and positional parameters and other attributes to add to this commandannotatedElement
- the `@Mixin`-annotated program elementmixinAnnotatedElements()
public CommandLine.Model.CommandSpec addMixin(String name, CommandLine.Model.CommandSpec mixin)
CommandSpec
object to the map of mixins for this command.name
- the name that can be used to later retrieve the mixinmixin
- the mixin whose options and positional parameters and other attributes to add to this commandpublic CommandLine.Model.CommandSpec addUnmatchedArgsBinding(CommandLine.Model.UnmatchedArgsBinding spec)
UnmatchedArgsBinding
to the list of model objects to capture unmatched arguments for this command.spec
- the unmatched arguments binding to capture unmatched argumentspublic CommandLine.Model.CommandSpec addSpecElement(CommandLine.Model.IAnnotatedElement spec)
{@literal @}Spec
-annotated program element to the list of elements for this command.public CommandLine.Model.CommandSpec addParentCommandElement(CommandLine.Model.IAnnotatedElement spec)
{@literal @}ParentCommand
-annotated program element to the list of elements for this command.public Map<String,CommandLine.Model.CommandSpec> mixins()
CommandSpec
objects configured for this command.public Map<String,CommandLine.Model.IAnnotatedElement> mixinAnnotatedElements()
IAnnotatedElement
objects for this command.addMixin(String, CommandLine.Model.CommandSpec, CommandLine.Model.IAnnotatedElement)
public List<CommandLine.Model.OptionSpec> options()
public List<CommandLine.Model.PositionalParamSpec> positionalParameters()
public List<CommandLine.Model.ArgGroupSpec> argGroups()
public Map<String,CommandLine.Model.OptionSpec> optionsMap()
public Map<String,CommandLine.Model.OptionSpec> negatedOptionsMap()
public Map<Character,CommandLine.Model.OptionSpec> posixOptionsMap()
public List<CommandLine.Model.ArgSpec> requiredArgs()
public List<CommandLine.Model.UnmatchedArgsBinding> unmatchedArgsBindings()
UnmatchedArgumentsBindings
configured for this command;
each UnmatchedArgsBinding
captures the arguments that could not be matched to any options or positional parameters.public List<CommandLine.Model.IAnnotatedElement> specElements()
{@literal @}Spec
configured for this command.public List<CommandLine.Model.IAnnotatedElement> parentCommandElements()
{@literal @}ParentCommand
configured for this command.public String name()
DEFAULT_COMMAND_NAME
by default, initialized from CommandLine.Command.name()
if defined.qualifiedName()
public String[] aliases()
public List<CommandLine.Model.ArgSpec> args()
public String qualifiedName()
name
, preceded by the qualified name of the parent command, if any, separated by a space.DEFAULT_COMMAND_NAME
by default, initialized from CommandLine.Command.name()
and the parent command if defined.public String qualifiedName(String separator)
name
, preceded by the qualified name of the parent command, if this command has a parent command.separator
- the string to put between the names of the commands in the hierarchyDEFAULT_COMMAND_NAME
by default, initialized from CommandLine.Command.name()
and the parent command if any.public String[] version()
version provider
if one is set, otherwise the version literalspublic CommandLine.IVersionProvider versionProvider()
version()
strings.null
if the version strings should be returned from the version literals.public boolean helpCommand()
true
if this subcommand is a help command and picocli should not check for missing required
options and positional parameters on the parent commandCommandLine.Command.helpCommand()
public int exitCodeOnSuccess()
exitCodeOnSuccess
annotation.CommandLine.execute(String...)
public int exitCodeOnUsageHelp()
exitCodeOnVersionHelp
annotation.CommandLine.execute(String...)
public int exitCodeOnVersionHelp()
exitCodeOnUsageHelp
annotation.CommandLine.execute(String...)
public int exitCodeOnInvalidInput()
exitCodeOnInvalidInput
annotation.CommandLine.execute(String...)
public int exitCodeOnExecutionException()
exitCodeOnExecutionException
annotation.CommandLine.execute(String...)
public CommandLine.INegatableOptionTransformer negatableOptionTransformer()
INegatableOptionTransformer
used to create the negative form of negatable options.CommandLine.Option.negatable()
public boolean mixinStandardHelpOptions()
true
if the standard help options have been mixed in with this command, false
otherwise.public boolean subcommandsRepeatable()
CommandLine.Command.subcommandsRepeatable()
public String toString()
public CommandLine.Model.CommandSpec name(String name)
public CommandLine.Model.CommandSpec aliases(String... aliases)
public CommandLine.IDefaultValueProvider defaultValueProvider()
null
public CommandLine.Model.CommandSpec defaultValueProvider(CommandLine.IDefaultValueProvider defaultValueProvider)
defaultValueProvider
- the default value provider to use, or null
.public CommandLine.Model.CommandSpec version(String... version)
versionProvider
is set.public CommandLine.Model.CommandSpec versionProvider(CommandLine.IVersionProvider versionProvider)
version()
strings.versionProvider
- the version provider to use to generate the version strings, or null
if the version literals should be used.public CommandLine.Model.CommandSpec helpCommand(boolean newValue)
CommandLine.Command.helpCommand()
public CommandLine.Model.CommandSpec exitCodeOnSuccess(int newValue)
CommandLine.execute(String...)
public CommandLine.Model.CommandSpec exitCodeOnUsageHelp(int newValue)
CommandLine.execute(String...)
public CommandLine.Model.CommandSpec exitCodeOnVersionHelp(int newValue)
CommandLine.execute(String...)
public CommandLine.Model.CommandSpec exitCodeOnInvalidInput(int newValue)
CommandLine.execute(String...)
public CommandLine.Model.CommandSpec exitCodeOnExecutionException(int newValue)
CommandLine.execute(String...)
public boolean inherited()
CommandLine.Command.scope()
public CommandLine.ScopeType scopeType()
public CommandLine.Model.CommandSpec scopeType(CommandLine.ScopeType scopeType)
public CommandLine.IModelTransformer modelTransformer()
public CommandLine.Model.CommandSpec modelTransformer(CommandLine.IModelTransformer modelTransformer)
public CommandLine.IParameterPreprocessor preprocessor()
public CommandLine.Model.CommandSpec preprocessor(CommandLine.IParameterPreprocessor preprocessor)
public CommandLine.Model.CommandSpec negatableOptionTransformer(CommandLine.INegatableOptionTransformer newValue)
INegatableOptionTransformer
used to create the negative form of negatable options.
Note that optionsCaseInsensitive()
will also change the case sensitivity of negatable options:
any custom CommandLine.INegatableOptionTransformer
that was previously installed will be replaced by the case-insensitive
version of the default transformer. To ensure your custom transformer is used, install it last, after changing case sensitivity.CommandLine.Option.negatable()
public CommandLine.Model.CommandSpec mixinStandardHelpOptions(boolean newValue)
CommandLine.Command.mixinStandardHelpOptions()
public CommandLine.Model.CommandSpec subcommandsRepeatable(boolean subcommandsRepeatable)
CommandLine.Command.subcommandsRepeatable()
public CommandLine.Model.CommandSpec withToString(String newValue)
newValue
- the string representationpublic void updateCommandAttributes(CommandLine.Command cmd, CommandLine.IFactory factory)
@Command
annotation:
aliases, parser separator
, command name, version, help command,
version provider, default provider and usage message spec
.cmd
- the @Command
annotation to get attribute values fromfactory
- factory used to instantiate classespublic CommandLine.Model.OptionSpec findOption(char shortName)
null
if no option with that name is defined for this command.public CommandLine.Model.OptionSpec findOption(String name)
null
if no option with that name is defined for this command.name
- used to search the options. May include option name prefix characters or not.