Class CommandLine.Model.CommandSpec
- java.lang.Object
-
- picocli.CommandLine.Model.CommandSpec
-
- Enclosing class:
- CommandLine.Model
public static class CommandLine.Model.CommandSpec extends java.lang.ObjectTheCommandSpecclass 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
mainmethod) 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
CommandSpecobjects, each with a set ofCommandLine.Model.OptionSpec,CommandLine.Model.PositionalParamSpecand subcommands associated with it. This object model is used by the picocli command line interpreter and help message generator.Picocli can construct a
CommandSpecautomatically from classes with@Command,@Optionand@Parametersannotations. Alternatively aCommandSpeccan be constructed programmatically.- Since:
- 3.0
-
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description privateCommandSpec(CommandLine.Model.CommandUserObject userObject)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandLine.Model.CommandSpecadd(CommandLine.Model.ArgSpec arg)Adds the specified option spec or positional parameter spec to the list of configured arguments to expect.private CommandLine.Model.CommandSpecaddArg(CommandLine.Model.ArgSpec arg)CommandLine.Model.CommandSpecaddArgGroup(CommandLine.Model.ArgGroupSpec group)Adds the specified argument group to the groups in this command.private CommandLine.Model.CommandSpecaddArgGroup(CommandLine.Model.ArgGroupSpec group, java.util.Set<CommandLine.Model.OptionSpec> groupOptions, java.util.Set<CommandLine.Model.PositionalParamSpec> groupPositionals)private voidaddGroupArgsToCommand(CommandLine.Model.ArgGroupSpec group, java.util.Map<java.lang.String,CommandLine.Model.ArgGroupSpec> added, java.util.Set<CommandLine.Model.OptionSpec> groupOptions, java.util.Set<CommandLine.Model.PositionalParamSpec> groupPositionals)CommandLine.Model.CommandSpecaddMethodSubcommands()Reflects on the class of the user object and registers any command methods (class methods annotated with@Command) as subcommands.CommandLine.Model.CommandSpecaddMethodSubcommands(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.CommandSpecaddMixin(java.lang.String name, CommandLine.Model.CommandSpec mixin)Adds the specified mixinCommandSpecobject to the map of mixins for this command.CommandLine.Model.CommandSpecaddMixin(java.lang.String name, CommandLine.Model.CommandSpec mixin, CommandLine.Model.IAnnotatedElement annotatedElement)Adds the specified mixinCommandSpecobject to the map of mixins for this command.CommandLine.Model.CommandSpecaddOption(CommandLine.Model.OptionSpec option)Adds the specified option spec to the list of configured arguments to expect.private voidaddOptionNegative(CommandLine.Model.OptionSpec option, CommandLine.Tracer tracer)CommandLine.Model.CommandSpecaddParentCommandElement(CommandLine.Model.IAnnotatedElement spec)Adds the specified{@literal @}ParentCommand-annotated program element to the list of elements for this command.CommandLine.Model.CommandSpecaddPositional(CommandLine.Model.PositionalParamSpec positional)Adds the specified positional parameter spec to the list of configured arguments to expect.CommandLine.Model.CommandSpecaddSpecElement(CommandLine.Model.IAnnotatedElement spec)Adds the specified{@literal @}Spec-annotated program element to the list of elements for this command.CommandLine.Model.CommandSpecaddSubcommand(java.lang.String name, CommandLine subCommandLine)Adds the specified subcommand with the specified name.CommandLine.Model.CommandSpecaddSubcommand(java.lang.String name, CommandLine.Model.CommandSpec subcommand)Adds the specified subcommand with the specified name.CommandLine.Model.CommandSpecaddUnmatchedArgsBinding(CommandLine.Model.UnmatchedArgsBinding spec)Adds the specifiedUnmatchedArgsBindingto the list of model objects to capture unmatched arguments for this command.private voidadjustRelativeIndices(CommandLine.Model.PositionalParamSpec newlyAdded)Adjusts the index of the new positional param and all others with relative indices that were sorted after this positional.java.lang.String[]aliases()Returns the alias command names of this subcommand.CommandLine.Model.CommandSpecaliases(java.lang.String... aliases)Sets the alternative names by which this subcommand is recognized on the command line.java.util.List<CommandLine.Model.ArgGroupSpec>argGroups()Returns the argument groups in this command.java.util.List<CommandLine.Model.ArgSpec>args()Returns the list of all options and positional parameters configured for this command.private voidcheck(CommandLine.Model.ArgGroupSpec group, java.util.Set<CommandLine.Model.ArgGroupSpec> existing)CommandLinecommandLine()Returns the CommandLine constructed with thisCommandSpecmodel.protected CommandLine.Model.CommandSpeccommandLine(CommandLine commandLine)Sets the CommandLine constructed with thisCommandSpecmodel.(package private) java.lang.Object[]commandMethodParamValues()private CommandLine.Model.CommandSpeccopy()static CommandLine.Model.CommandSpeccreate()Creates and returns a newCommandSpecwithout any associated user object.(package private) static java.util.List<CommandLine>createMethodSubcommands(java.lang.Class<?> cls, CommandLine.IFactory factory, boolean includeInherited)CommandLine.IDefaultValueProviderdefaultValueProvider()Returns the default value provider for this command.CommandLine.Model.CommandSpecdefaultValueProvider(CommandLine.IDefaultValueProvider defaultValueProvider)Sets default value provider for this command.intexitCodeOnExecutionException()Returns exit code signifying that an exception occurred when invoking the Runnable, Callable or Method user object of a command.CommandLine.Model.CommandSpecexitCodeOnExecutionException(int newValue)Sets exit code signifying that an exception occurred when invoking the Runnable, Callable or Method user object of a command.intexitCodeOnInvalidInput()Returns exit code for command line usage error.CommandLine.Model.CommandSpecexitCodeOnInvalidInput(int newValue)Sets exit code for command line usage error.intexitCodeOnSuccess()Returns exit code for successful termination.CommandLine.Model.CommandSpecexitCodeOnSuccess(int newValue)Sets exit code for successful termination.intexitCodeOnUsageHelp()Returns exit code for successful termination after printing usage help on user request.CommandLine.Model.CommandSpecexitCodeOnUsageHelp(int newValue)Sets exit code for successful termination after printing usage help on user request.intexitCodeOnVersionHelp()Returns exit code for successful termination after printing version help on user request.CommandLine.Model.CommandSpecexitCodeOnVersionHelp(int newValue)Sets exit code for successful termination after printing version help on user request.CommandLine.Model.OptionSpecfindOption(char shortName)Returns the option with the specified short name, ornullif no option with that name is defined for this command.(package private) static CommandLine.Model.OptionSpecfindOption(char shortName, java.lang.Iterable<CommandLine.Model.OptionSpec> options)CommandLine.Model.OptionSpecfindOption(java.lang.String name)Returns the option with the specified name, ornullif no option with that name is defined for this command.(package private) static CommandLine.Model.OptionSpecfindOption(java.lang.String name, java.util.List<CommandLine.Model.OptionSpec> options)(package private) java.util.List<java.lang.String>findVisibleOptionNamesWithPrefix(java.lang.String prefix)private java.util.Set<CommandLine.Model.ArgGroupSpec>flatten(java.util.Collection<CommandLine.Model.ArgGroupSpec> groups, java.util.Set<CommandLine.Model.ArgGroupSpec> result)private java.util.Set<CommandLine.Model.ArgGroupSpec>flatten(CommandLine.Model.ArgGroupSpec group, java.util.Set<CommandLine.Model.ArgGroupSpec> result)static CommandLine.Model.CommandSpecforAnnotatedObject(java.lang.Object userObject)Creates and returns a newCommandSpecinitialized from the specified associated user object.static CommandLine.Model.CommandSpecforAnnotatedObject(java.lang.Object userObject, CommandLine.IFactory factory)Creates and returns a newCommandSpecinitialized from the specified associated user object.static CommandLine.Model.CommandSpecforAnnotatedObjectLenient(java.lang.Object userObject)Creates and returns a newCommandSpecinitialized from the specified associated user object.static CommandLine.Model.CommandSpecforAnnotatedObjectLenient(java.lang.Object userObject, CommandLine.IFactory factory)Creates and returns a newCommandSpecinitialized from the specified associated user object.booleanhelpCommand()Returns whether this subcommand is a help command, and required options and positional parameters of the parent command should not be validated.CommandLine.Model.CommandSpechelpCommand(boolean newValue)Sets whether this is a help command and required parameter checking should be suspended.private voidinheritAttributesFrom(CommandLine.Model.CommandSpec root)booleaninherited()Returns whether this command is inherited from a parent command.private voidinitCommandHierarchyWithResourceBundle(java.lang.String bundleBaseName, java.util.ResourceBundle rb)(package private) voidinitDefaultValueProvider(java.lang.Class<? extends CommandLine.IDefaultValueProvider> value, CommandLine.IFactory factory)(package private) voidinitDefaultValueProvider(CommandLine.IDefaultValueProvider value)(package private) voidinitExitCodeOnExecutionException(int exitCode)(package private) voidinitExitCodeOnInvalidInput(int exitCode)(package private) voidinitExitCodeOnSuccess(int exitCode)(package private) voidinitExitCodeOnUsageHelp(int exitCode)(package private) voidinitExitCodeOnVersionHelp(int exitCode)private voidinitFrom(CommandLine.Model.CommandSpec spec)(package private) voidinitHelpCommand(boolean value)(package private) voidinitModelTransformer(CommandLine.IModelTransformer value)(package private) voidinitName(java.lang.String value)(package private) voidinitPreprocessor(CommandLine.IParameterPreprocessor value)(package private) voidinitSubcommandsRepeatable(boolean value)(package private) voidinitVersion(java.lang.String[] value)(package private) voidinitVersionProvider(CommandLine.IVersionProvider value)(package private) voidinjectParentCommand(CommandLine.Model.CommandUserObject commandUserObject)booleaninterpolateVariables()Returns whether whether variables should be interpolated in String values.CommandLine.Model.CommandSpecinterpolateVariables(java.lang.Boolean interpolate)Sets whether whether variables should be interpolated in String values.booleanisAddMethodSubcommands()Returns whether method commands should be added as subcommands.java.util.Map<java.lang.String,CommandLine.Model.IAnnotatedElement>mixinAnnotatedElements()Returns a map of the mixin names to mixinIAnnotatedElementobjects for this command.java.util.Map<java.lang.String,CommandLine.Model.CommandSpec>mixins()Returns a map of the mixin names to mixinCommandSpecobjects configured for this command.booleanmixinStandardHelpOptions()Returnstrueif the standard help options have been mixed in with this command,falseotherwise.CommandLine.Model.CommandSpecmixinStandardHelpOptions(boolean newValue)Sets whether the standard help options should be mixed in with this command.CommandLine.IModelTransformermodelTransformer()Returns the model transformer for this CommandSpec instance.CommandLine.Model.CommandSpecmodelTransformer(CommandLine.IModelTransformer modelTransformer)Sets the model transformer for this CommandSpec instance.java.lang.Stringname()Returns name of this command.CommandLine.Model.CommandSpecname(java.lang.String name)Sets the String to use as the program name in the synopsis line of the help message.java.util.Set<java.lang.String>names()CommandLine.INegatableOptionTransformernegatableOptionTransformer()Returns theINegatableOptionTransformerused to create the negative form of negatable options.CommandLine.Model.CommandSpecnegatableOptionTransformer(CommandLine.INegatableOptionTransformer newValue)Sets theINegatableOptionTransformerused to create the negative form of negatable options.java.util.Map<java.lang.String,CommandLine.Model.OptionSpec>negatedOptionsMap()Returns a map of the negated option names to option spec objects configured for this command.java.util.List<CommandLine.Model.OptionSpec>options()Returns the list of options configured for this command.booleanoptionsCaseInsensitive()Returns whether the options are case-insensitive.CommandLine.Model.CommandSpecoptionsCaseInsensitive(boolean caseInsensitiveOptions)Sets the case-insensitivity of options.java.util.Map<java.lang.String,CommandLine.Model.OptionSpec>optionsMap()Returns a map of the option names to option spec objects configured for this command.CommandLine.Model.CommandSpecparent()Returns the parent command of this subcommand, ornullif this is a top-level command.CommandLine.Model.CommandSpecparent(CommandLine.Model.CommandSpec parent)Sets the parent command of this subcommand.java.util.List<CommandLine.Model.IAnnotatedElement>parentCommandElements()Returns the list of program elements annotated with{@literal @}ParentCommandconfigured for this command.CommandLine.Model.ParserSpecparser()Returns the parser specification for this command.CommandLine.Model.CommandSpecparser(CommandLine.Model.ParserSpec settings)Initializes the parser specification for this command from the specified settings and returns this commandSpec.java.util.List<CommandLine.Model.PositionalParamSpec>positionalParameters()Returns the list of positional parameters configured for this command.java.util.Map<java.lang.Character,CommandLine.Model.OptionSpec>posixOptionsMap()Returns a map of the short (single character) option names to option spec objects configured for this command.CommandLine.IParameterPreprocessorpreprocessor()Returns the preprocessor for this CommandSpec instance.CommandLine.Model.CommandSpecpreprocessor(CommandLine.IParameterPreprocessor preprocessor)Sets the preprocessor for this CommandSpec instance.java.lang.StringqualifiedName()Returns the String to use as the program name in the synopsis line of the help message: this command'sname, preceded by the qualified name of the parent command, if any, separated by a space.java.lang.StringqualifiedName(java.lang.String separator)Returns this command's fully qualified name, which is itsname, preceded by the qualified name of the parent command, if this command has a parent command.CommandLine.Model.CommandSpecremove(CommandLine.Model.ArgSpec arg)(INCUBATING) Removes the specified option spec or positional parameter spec from the list of configured arguments to expect.private static <T> intremove(CommandLine.Model.ArgSpec arg, java.util.Map<T,CommandLine.Model.OptionSpec> map)CommandLineremoveSubcommand(java.lang.String name)Removes the subcommand with the specified name or alias from this CommandSpec and returns theCommandLineinstance that was associated with the specified name, ornullof the specified name was not associated with a subcommand.java.util.List<CommandLine.Model.ArgSpec>requiredArgs()Returns the list of required options and positional parameters configured for this command.(package private) booleanresemblesOption(java.lang.String arg, CommandLine.Tracer tracer)private voidresetNegativeOptionNames()java.util.ResourceBundleresourceBundle()Returns the resource bundle for this command.CommandLine.Model.CommandSpecresourceBundle(java.util.ResourceBundle bundle)Initializes the resource bundle for this command: sets theUsageMessageSpec.messagesto aMessagesobject created from this command spec and the specified bundle, and then sets theArgSpec.messagesof all options and positional parameters in this command to the sameMessagesinstance.java.lang.StringresourceBundleBaseName()Returns the resource bundle base name for this command.CommandLine.Model.CommandSpecresourceBundleBaseName(java.lang.String resourceBundleBaseName)Initializes the resource bundle for this command: sets theUsageMessageSpec.messagesto aMessagesobject created from this command spec and the specified bundle, and then sets theArgSpec.messagesof all options and positional parameters in this command to the sameMessagesinstance.CommandLine.Model.CommandSpecroot()Returns the root command: the top-level command of the hierarchy, nevernull.CommandLine.ScopeTypescopeType()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.CommandSpecscopeType(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.CommandSpecsetAddMethodSubcommands(java.lang.Boolean addMethodSubcommands)Sets whether method commands should be added as subcommands.private voidsetBundle(java.lang.String bundleBaseName, java.util.ResourceBundle bundle)java.util.List<CommandLine.Model.IAnnotatedElement>specElements()Returns the list of program elements annotated with{@literal @}Specconfigured for this command.(package private) static java.lang.StringstripPrefix(java.lang.String prefixed)java.util.Map<java.lang.String,CommandLine>subcommands()Returns a read-only view of the subcommand map.booleansubcommandsCaseInsensitive()Returns whether the subcommands are case-insensitive.CommandLine.Model.CommandSpecsubcommandsCaseInsensitive(boolean caseInsensitiveSubcommands)Sets the case-insensitivity of subcommands.booleansubcommandsRepeatable()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.CommandSpecsubcommandsRepeatable(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.java.lang.StringtoString()Returns a string representation of this command, used in error messages and trace messages.java.util.List<CommandLine.Model.UnmatchedArgsBinding>unmatchedArgsBindings()Returns the list ofUnmatchedArgumentsBindingsconfigured for this command; eachUnmatchedArgsBindingcaptures the arguments that could not be matched to any options or positional parameters.(package private) voidupdateAddMethodSubcommands(boolean value)private voidupdateArgSpecMessages()voidupdateCommandAttributes(CommandLine.Command cmd, CommandLine.IFactory factory)Updates the following attributes from the specified@Commandannotation: aliases,parser separator, command name, version, help command, version provider, default provider andusage message spec.private voidupdatedSubcommandsToInheritFrom(CommandLine.Model.CommandSpec root)(package private) voidupdateExitCodeOnExecutionException(int exitCode)(package private) voidupdateExitCodeOnInvalidInput(int exitCode)(package private) voidupdateExitCodeOnSuccess(int exitCode)(package private) voidupdateExitCodeOnUsageHelp(int exitCode)(package private) voidupdateExitCodeOnVersionHelp(int exitCode)(package private) voidupdateHelpCommand(boolean value)(package private) voidupdateModelTransformer(java.lang.Class<? extends CommandLine.IModelTransformer> value, CommandLine.IFactory factory)(package private) voidupdateName(java.lang.String value)(package private) voidupdatePreprocessor(java.lang.Class<? extends CommandLine.IParameterPreprocessor> value, CommandLine.IFactory factory)(package private) voidupdateScopeType(CommandLine.ScopeType scopeType)(package private) voidupdateSubcommandsRepeatable(boolean value)(package private) voidupdateVersion(java.lang.String[] value)(package private) voidupdateVersionProvider(java.lang.Class<? extends CommandLine.IVersionProvider> value, CommandLine.IFactory factory)CommandLine.Model.UsageMessageSpecusageMessage()Returns the usage help message specification for this command.CommandLine.Model.CommandSpecusageMessage(CommandLine.Model.UsageMessageSpec settings)Initializes the usageMessage specification for this command from the specified settings and returns this commandSpec.java.lang.ObjectuserObject()Returns the user object associated with this command.(package private) voidvalidate()Ensures all attributes of thisCommandSpechave a valid value; throws anCommandLine.InitializationExceptionif this cannot be achieved.private java.lang.StringvalidateSubcommandName(java.lang.String name, CommandLine.Model.CommandSpec subSpec)java.lang.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.CommandSpecversion(java.lang.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.IVersionProviderversionProvider()Returns the version provider for this command, to generate theversion()strings.CommandLine.Model.CommandSpecversionProvider(CommandLine.IVersionProvider versionProvider)Sets version provider for this command, to generate theversion()strings.CommandLine.Model.CommandSpecwithToString(java.lang.String newValue)Sets the string representation of this command, used in error messages and trace messages.static CommandLine.Model.CommandSpecwrapWithoutInspection(java.lang.Object userObject)Creates and returns a newCommandSpecwith the specified associated user object.static CommandLine.Model.CommandSpecwrapWithoutInspection(java.lang.Object userObject, CommandLine.IFactory factory)Creates and returns a newCommandSpecwith the specified associated user object.
-
-
-
Field Detail
-
DEFAULT_COMMAND_NAME
public static final java.lang.String DEFAULT_COMMAND_NAME
Constant String holding the default program name:"<main class>".- Since:
- 4.0
- See Also:
- Constant Field Values
-
DEFAULT_IS_HELP_COMMAND
static final java.lang.Boolean DEFAULT_IS_HELP_COMMAND
Constant Boolean holding the default setting for whether this is a help command:.
-
DEFAULT_IS_ADD_METHOD_SUBCOMMANDS
static final java.lang.Boolean DEFAULT_IS_ADD_METHOD_SUBCOMMANDS
Constant Boolean holding the default setting for whether method commands should be added as subcommands:.
-
DEFAULT_INTERPOLATE_VARIABLES
static final java.lang.Boolean DEFAULT_INTERPOLATE_VARIABLES
Constant Boolean holding the default setting for whether variables should be interpolated in String values:.
-
DEFAULT_SUBCOMMANDS_REPEATABLE
static final java.lang.Boolean DEFAULT_SUBCOMMANDS_REPEATABLE
-
commands
private final CommandLine.Model.CaseAwareLinkedMap<java.lang.String,CommandLine> commands
-
optionsByNameMap
private final CommandLine.Model.CaseAwareLinkedMap<java.lang.String,CommandLine.Model.OptionSpec> optionsByNameMap
-
negatedOptionsByNameMap
private final CommandLine.Model.CaseAwareLinkedMap<java.lang.String,CommandLine.Model.OptionSpec> negatedOptionsByNameMap
-
posixOptionsByKeyMap
private final CommandLine.Model.CaseAwareLinkedMap<java.lang.Character,CommandLine.Model.OptionSpec> posixOptionsByKeyMap
-
mixins
private final java.util.Map<java.lang.String,CommandLine.Model.CommandSpec> mixins
-
mixinAnnotatedElements
private final java.util.Map<java.lang.String,CommandLine.Model.IAnnotatedElement> mixinAnnotatedElements
-
requiredArgs
private final java.util.List<CommandLine.Model.ArgSpec> requiredArgs
-
args
private final java.util.List<CommandLine.Model.ArgSpec> args
-
options
private final java.util.List<CommandLine.Model.OptionSpec> options
-
positionalParameters
private final java.util.List<CommandLine.Model.PositionalParamSpec> positionalParameters
-
unmatchedArgs
private final java.util.List<CommandLine.Model.UnmatchedArgsBinding> unmatchedArgs
-
specElements
private final java.util.List<CommandLine.Model.IAnnotatedElement> specElements
-
parentCommandElements
private final java.util.List<CommandLine.Model.IAnnotatedElement> parentCommandElements
-
groups
private final java.util.List<CommandLine.Model.ArgGroupSpec> groups
-
parser
private final CommandLine.Model.ParserSpec parser
-
interpolator
private final CommandLine.Model.Interpolator interpolator
-
usageMessage
private final CommandLine.Model.UsageMessageSpec usageMessage
-
methodParams
private CommandLine.Model.TypedMember[] methodParams
-
userObject
private final CommandLine.Model.CommandUserObject userObject
-
commandLine
private CommandLine commandLine
-
parent
private CommandLine.Model.CommandSpec parent
-
isAddMethodSubcommands
private java.lang.Boolean isAddMethodSubcommands
-
interpolateVariables
private java.lang.Boolean interpolateVariables
-
name
private java.lang.String name
-
aliases
private java.util.Set<java.lang.String> aliases
-
isHelpCommand
private java.lang.Boolean isHelpCommand
-
versionProvider
private CommandLine.IVersionProvider versionProvider
-
defaultValueProvider
private CommandLine.IDefaultValueProvider defaultValueProvider
-
negatableOptionTransformer
private CommandLine.INegatableOptionTransformer negatableOptionTransformer
-
subcommandsRepeatable
private java.lang.Boolean subcommandsRepeatable
-
version
private java.lang.String[] version
-
toString
private java.lang.String toString
-
inherited
private boolean inherited
-
scopeType
private CommandLine.ScopeType scopeType
-
exitCodeOnSuccess
private java.lang.Integer exitCodeOnSuccess
-
exitCodeOnUsageHelp
private java.lang.Integer exitCodeOnUsageHelp
-
exitCodeOnVersionHelp
private java.lang.Integer exitCodeOnVersionHelp
-
exitCodeOnInvalidInput
private java.lang.Integer exitCodeOnInvalidInput
-
exitCodeOnExecutionException
private java.lang.Integer exitCodeOnExecutionException
-
modelTransformer
private CommandLine.IModelTransformer modelTransformer
-
preprocessor
private CommandLine.IParameterPreprocessor preprocessor
-
-
Constructor Detail
-
CommandSpec
private CommandSpec(CommandLine.Model.CommandUserObject userObject)
-
-
Method Detail
-
copy
private CommandLine.Model.CommandSpec copy()
-
create
public static CommandLine.Model.CommandSpec create()
Creates and returns a newCommandSpecwithout any associated user object.
-
wrapWithoutInspection
public static CommandLine.Model.CommandSpec wrapWithoutInspection(java.lang.Object userObject)
Creates and returns a newCommandSpecwith the specified associated user object. The specified user object is not inspected for annotations.- Parameters:
userObject- the associated user object. May be any object, may benull.
-
wrapWithoutInspection
public static CommandLine.Model.CommandSpec wrapWithoutInspection(java.lang.Object userObject, CommandLine.IFactory factory)
Creates and returns a newCommandSpecwith the specified associated user object. The specified user object is not inspected for annotations.- Parameters:
userObject- the associated user object. May be any object, may benull.factory- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributes- Since:
- 4.2
-
forAnnotatedObject
public static CommandLine.Model.CommandSpec forAnnotatedObject(java.lang.Object userObject)
Creates and returns a newCommandSpecinitialized from the specified associated user object. The specified user object must have at least oneCommandLine.Command,CommandLine.OptionorCommandLine.Parametersannotation.- Parameters:
userObject- the user object annotated withCommandLine.Command,CommandLine.Optionand/orCommandLine.Parametersannotations.- Throws:
CommandLine.InitializationException- if the specified object has no picocli annotations or has invalid annotations
-
forAnnotatedObject
public static CommandLine.Model.CommandSpec forAnnotatedObject(java.lang.Object userObject, CommandLine.IFactory factory)
Creates and returns a newCommandSpecinitialized from the specified associated user object. The specified user object must have at least oneCommandLine.Command,CommandLine.OptionorCommandLine.Parametersannotation.- Parameters:
userObject- the user object annotated withCommandLine.Command,CommandLine.Optionand/orCommandLine.Parametersannotations.factory- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributes- Throws:
CommandLine.InitializationException- if the specified object has no picocli annotations or has invalid annotations
-
forAnnotatedObjectLenient
public static CommandLine.Model.CommandSpec forAnnotatedObjectLenient(java.lang.Object userObject)
Creates and returns a newCommandSpecinitialized from the specified associated user object. If the specified user object has noCommandLine.Command,CommandLine.OptionorCommandLine.Parametersannotations, an emptyCommandSpecis returned.- Parameters:
userObject- the user object annotated withCommandLine.Command,CommandLine.Optionand/orCommandLine.Parametersannotations.- Throws:
CommandLine.InitializationException- if the specified object has invalid annotations
-
forAnnotatedObjectLenient
public static CommandLine.Model.CommandSpec forAnnotatedObjectLenient(java.lang.Object userObject, CommandLine.IFactory factory)
Creates and returns a newCommandSpecinitialized from the specified associated user object. If the specified user object has noCommandLine.Command,CommandLine.OptionorCommandLine.Parametersannotations, an emptyCommandSpecis returned.- Parameters:
userObject- the user object annotated withCommandLine.Command,CommandLine.Optionand/orCommandLine.Parametersannotations.factory- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributes- Throws:
CommandLine.InitializationException- if the specified object has invalid annotations
-
validate
void validate()
Ensures all attributes of thisCommandSpechave a valid value; throws anCommandLine.InitializationExceptionif this cannot be achieved.
-
userObject
public java.lang.Object userObject()
Returns the user object associated with this command.- See Also:
CommandLine.getCommand()
-
commandLine
public CommandLine commandLine()
Returns the CommandLine constructed with thisCommandSpecmodel.
-
commandLine
protected CommandLine.Model.CommandSpec commandLine(CommandLine commandLine)
Sets the CommandLine constructed with thisCommandSpecmodel.
-
parser
public CommandLine.Model.ParserSpec parser()
Returns the parser specification for this command.
-
parser
public CommandLine.Model.CommandSpec parser(CommandLine.Model.ParserSpec settings)
Initializes the parser specification for this command from the specified settings and returns this commandSpec.
-
usageMessage
public CommandLine.Model.UsageMessageSpec usageMessage()
Returns the usage help message specification for this command.
-
usageMessage
public CommandLine.Model.CommandSpec usageMessage(CommandLine.Model.UsageMessageSpec settings)
Initializes the usageMessage specification for this command from the specified settings and returns this commandSpec.
-
subcommandsCaseInsensitive
public boolean subcommandsCaseInsensitive()
Returns whether the subcommands are case-insensitive.- Since:
- 4.3
-
subcommandsCaseInsensitive
public CommandLine.Model.CommandSpec subcommandsCaseInsensitive(boolean caseInsensitiveSubcommands)
Sets the case-insensitivity of subcommands.- Since:
- 4.3
-
optionsCaseInsensitive
public boolean optionsCaseInsensitive()
Returns whether the options are case-insensitive.- Since:
- 4.3
-
optionsCaseInsensitive
public CommandLine.Model.CommandSpec optionsCaseInsensitive(boolean caseInsensitiveOptions)
Sets the case-insensitivity of options. Note that changing case sensitivity will also change the case sensitivity of negatable options: any customCommandLine.INegatableOptionTransformerthat 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.- Since:
- 4.3
-
resourceBundleBaseName
public java.lang.String resourceBundleBaseName()
Returns the resource bundle base name for this command.- Returns:
- the resource bundle base name from the CommandLine.Model.UsageMessageSpec.messages()
- Since:
- 4.0
-
resourceBundleBaseName
public CommandLine.Model.CommandSpec resourceBundleBaseName(java.lang.String resourceBundleBaseName)
Initializes the resource bundle for this command: sets theUsageMessageSpec.messagesto aMessagesobject created from this command spec and the specified bundle, and then sets theArgSpec.messagesof all options and positional parameters in this command to the sameMessagesinstance. Subcommands are not modified.This method is preferable to
resourceBundle(ResourceBundle)for pre-Java 8- Parameters:
resourceBundleBaseName- the base name of the ResourceBundle to set, may benull- Returns:
- this commandSpec
- Since:
- 4.0
- See Also:
addSubcommand(String, CommandLine)
-
resourceBundle
public java.util.ResourceBundle resourceBundle()
Returns the resource bundle for this command.- Returns:
- the resource bundle from the CommandLine.Model.UsageMessageSpec.messages()
- Since:
- 3.6
-
resourceBundle
public CommandLine.Model.CommandSpec resourceBundle(java.util.ResourceBundle bundle)
Initializes the resource bundle for this command: sets theUsageMessageSpec.messagesto aMessagesobject created from this command spec and the specified bundle, and then sets theArgSpec.messagesof all options and positional parameters in this command to the sameMessagesinstance. Subcommands are not modified.- Parameters:
bundle- the ResourceBundle to set, may benull- Returns:
- this commandSpec
- Since:
- 3.6
- See Also:
addSubcommand(String, CommandLine)
-
setBundle
private void setBundle(java.lang.String bundleBaseName, java.util.ResourceBundle bundle)
-
updateArgSpecMessages
private void updateArgSpecMessages()
-
subcommands
public java.util.Map<java.lang.String,CommandLine> subcommands()
Returns a read-only view of the subcommand map.
-
addSubcommand
public CommandLine.Model.CommandSpec addSubcommand(java.lang.String name, CommandLine.Model.CommandSpec subcommand)
Adds the specified subcommand with the specified name. If the specified subcommand does not have a ResourceBundle set, it is initialized to the ResourceBundle of this command spec.- Parameters:
name- subcommand name - the preferred subcommand name to register the subcommand under. Ifnull, the name of the specified subcommand is used; if this is alsonull, 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 line- Returns:
- this
CommandSpecobject for method chaining - Throws:
CommandLine.InitializationException- if the specified name isnull, 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.
-
addSubcommand
public CommandLine.Model.CommandSpec addSubcommand(java.lang.String name, CommandLine subCommandLine)
Adds the specified subcommand with the specified name. If the specified subcommand does not have a ResourceBundle set, it is initialized to the ResourceBundle of this command spec.- Parameters:
name- subcommand name - the preferred subcommand name to register the subcommand under. Ifnull, the name of the specified subcommand is used; if this is alsonull, 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 line- Returns:
- this
CommandSpecobject for method chaining - Throws:
CommandLine.InitializationException- if the specified name isnull, 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.
-
inheritAttributesFrom
private void inheritAttributesFrom(CommandLine.Model.CommandSpec root)
-
updatedSubcommandsToInheritFrom
private void updatedSubcommandsToInheritFrom(CommandLine.Model.CommandSpec root)
-
removeSubcommand
public CommandLine removeSubcommand(java.lang.String name)
Removes the subcommand with the specified name or alias from this CommandSpec and returns theCommandLineinstance that was associated with the specified name, ornullof the specified name was not associated with a subcommand.- Parameters:
name- name or alias of the subcommand to remove; may beabbreviatedorcase-insensitive- Returns:
- the removed
CommandLineinstance ornull - Since:
- 4.6
-
validateSubcommandName
private java.lang.String validateSubcommandName(java.lang.String name, CommandLine.Model.CommandSpec subSpec)
-
initCommandHierarchyWithResourceBundle
private void initCommandHierarchyWithResourceBundle(java.lang.String bundleBaseName, java.util.ResourceBundle rb)
-
isAddMethodSubcommands
public boolean isAddMethodSubcommands()
Returns whether method commands should be added as subcommands. True by default. Used by the annotation processor.- Since:
- 4.0
-
setAddMethodSubcommands
public CommandLine.Model.CommandSpec setAddMethodSubcommands(java.lang.Boolean addMethodSubcommands)
Sets whether method commands should be added as subcommands. True by default. Used by the annotation processor.- Since:
- 4.0
-
interpolateVariables
public boolean interpolateVariables()
Returns whether whether variables should be interpolated in String values. True by default.- Since:
- 4.0
-
interpolateVariables
public CommandLine.Model.CommandSpec interpolateVariables(java.lang.Boolean interpolate)
Sets whether whether variables should be interpolated in String values. True by default.- Since:
- 4.0
-
addMethodSubcommands
public CommandLine.Model.CommandSpec addMethodSubcommands()
Reflects on the class of the user object and registers any command methods (class methods annotated with@Command) as subcommands.- Returns:
- this
CommandLine.Model.CommandSpecobject for method chaining - Since:
- 3.6.0
- See Also:
addMethodSubcommands(CommandLine.IFactory),addSubcommand(String, CommandLine)
-
addMethodSubcommands
public 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.- Parameters:
factory- the factory used to create instances of subcommands, converters, etc., that are registered declaratively with annotation attributes- Returns:
- this
CommandLine.Model.CommandSpecobject for method chaining - Since:
- 3.7.0
- See Also:
addSubcommand(String, CommandLine)
-
createMethodSubcommands
static java.util.List<CommandLine> createMethodSubcommands(java.lang.Class<?> cls, CommandLine.IFactory factory, boolean includeInherited)
-
parent
public CommandLine.Model.CommandSpec parent()
Returns the parent command of this subcommand, ornullif this is a top-level command.
-
root
public CommandLine.Model.CommandSpec root()
Returns the root command: the top-level command of the hierarchy, nevernull.- Since:
- 4.3
-
parent
public CommandLine.Model.CommandSpec parent(CommandLine.Model.CommandSpec parent)
Sets the parent command of this subcommand.- Returns:
- this CommandSpec for method chaining
-
add
public 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.- Parameters:
arg- the option spec or positional parameter spec to add- Returns:
- this CommandSpec for method chaining
-
addOption
public CommandLine.Model.CommandSpec addOption(CommandLine.Model.OptionSpec option)
Adds the specified option spec to the list of configured arguments to expect. The option's CommandLine.Model.ArgSpec.description() may now return Strings from this CommandSpec's messages. The option parameter's CommandLine.Model.ArgSpec.defaultValueString() may now return Strings from this CommandSpec'sdefaultValueProvider()IDefaultValueProvider}.- Parameters:
option- the option spec to add- Returns:
- this CommandSpec for method chaining
- Throws:
CommandLine.DuplicateOptionAnnotationsException- if any of the names of the specified option is the same as the name of another option
-
addOptionNegative
private void addOptionNegative(CommandLine.Model.OptionSpec option, CommandLine.Tracer tracer)
-
resetNegativeOptionNames
private void resetNegativeOptionNames()
-
addPositional
public CommandLine.Model.CommandSpec addPositional(CommandLine.Model.PositionalParamSpec positional)
Adds the specified positional parameter spec to the list of configured arguments to expect. The positional parameter's CommandLine.Model.ArgSpec.description() may now return Strings from this CommandSpec's messages. The positional parameter's CommandLine.Model.ArgSpec.defaultValueString() may now return Strings from this CommandSpec'sdefaultValueProvider()IDefaultValueProvider}.- Parameters:
positional- the positional parameter spec to add- Returns:
- this CommandSpec for method chaining
-
adjustRelativeIndices
private void adjustRelativeIndices(CommandLine.Model.PositionalParamSpec newlyAdded)
Adjusts the index of the new positional param and all others with relative indices that were sorted after this positional.- Parameters:
newlyAdded- the newly added positional parameter
-
addArg
private CommandLine.Model.CommandSpec addArg(CommandLine.Model.ArgSpec arg)
-
remove
public 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.- Parameters:
arg- the option spec or positional parameter spec to remove- Returns:
- this CommandSpec for method chaining
- Throws:
java.lang.UnsupportedOperationException- if the specified ArgSpec is part of aCommandLine.Model.ArgGroupSpecjava.util.NoSuchElementException- if the specified ArgSpec is not part of thisCommandSpec- Since:
- 4.0
-
remove
private static <T> int remove(CommandLine.Model.ArgSpec arg, java.util.Map<T,CommandLine.Model.OptionSpec> map)
-
addArgGroup
public CommandLine.Model.CommandSpec addArgGroup(CommandLine.Model.ArgGroupSpec group)
Adds the specified argument group to the groups in this command.- Parameters:
group- the group spec to add- Returns:
- this CommandSpec for method chaining
- Throws:
CommandLine.InitializationException- if the specified group or one of its ancestors has already been added- Since:
- 4.0
-
addArgGroup
private CommandLine.Model.CommandSpec addArgGroup(CommandLine.Model.ArgGroupSpec group, java.util.Set<CommandLine.Model.OptionSpec> groupOptions, java.util.Set<CommandLine.Model.PositionalParamSpec> groupPositionals)
-
addGroupArgsToCommand
private void addGroupArgsToCommand(CommandLine.Model.ArgGroupSpec group, java.util.Map<java.lang.String,CommandLine.Model.ArgGroupSpec> added, java.util.Set<CommandLine.Model.OptionSpec> groupOptions, java.util.Set<CommandLine.Model.PositionalParamSpec> groupPositionals)
-
flatten
private java.util.Set<CommandLine.Model.ArgGroupSpec> flatten(java.util.Collection<CommandLine.Model.ArgGroupSpec> groups, java.util.Set<CommandLine.Model.ArgGroupSpec> result)
-
flatten
private java.util.Set<CommandLine.Model.ArgGroupSpec> flatten(CommandLine.Model.ArgGroupSpec group, java.util.Set<CommandLine.Model.ArgGroupSpec> result)
-
check
private void check(CommandLine.Model.ArgGroupSpec group, java.util.Set<CommandLine.Model.ArgGroupSpec> existing)
-
addMixin
public CommandLine.Model.CommandSpec addMixin(java.lang.String name, CommandLine.Model.CommandSpec mixin, CommandLine.Model.IAnnotatedElement annotatedElement)
Adds the specified mixinCommandSpecobject to the map of mixins for this command.- Parameters:
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 element- Returns:
- this CommandSpec for method chaining
- Since:
- 4.1
- See Also:
mixinAnnotatedElements()
-
addMixin
public CommandLine.Model.CommandSpec addMixin(java.lang.String name, CommandLine.Model.CommandSpec mixin)
Adds the specified mixinCommandSpecobject to the map of mixins for this command.- Parameters:
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 command- Returns:
- this CommandSpec for method chaining
-
initFrom
private void initFrom(CommandLine.Model.CommandSpec spec)
-
addUnmatchedArgsBinding
public CommandLine.Model.CommandSpec addUnmatchedArgsBinding(CommandLine.Model.UnmatchedArgsBinding spec)
Adds the specifiedUnmatchedArgsBindingto the list of model objects to capture unmatched arguments for this command.- Parameters:
spec- the unmatched arguments binding to capture unmatched arguments- Returns:
- this CommandSpec for method chaining
-
addSpecElement
public CommandLine.Model.CommandSpec addSpecElement(CommandLine.Model.IAnnotatedElement spec)
Adds the specified{@literal @}Spec-annotated program element to the list of elements for this command.- Returns:
- this CommandSpec for method chaining
- Since:
- 4.0
-
addParentCommandElement
public CommandLine.Model.CommandSpec addParentCommandElement(CommandLine.Model.IAnnotatedElement spec)
Adds the specified{@literal @}ParentCommand-annotated program element to the list of elements for this command.- Returns:
- this CommandSpec for method chaining
- Since:
- 4.0
-
injectParentCommand
void injectParentCommand(CommandLine.Model.CommandUserObject commandUserObject)
-
mixins
public java.util.Map<java.lang.String,CommandLine.Model.CommandSpec> mixins()
Returns a map of the mixin names to mixinCommandSpecobjects configured for this command.- Returns:
- an immutable map of mixins added to this command.
-
mixinAnnotatedElements
public java.util.Map<java.lang.String,CommandLine.Model.IAnnotatedElement> mixinAnnotatedElements()
Returns a map of the mixin names to mixinIAnnotatedElementobjects for this command.- Returns:
- an immutable map of `@Mixin`-annotated elements added to this command.
- Since:
- 4.1
- See Also:
addMixin(String, CommandLine.Model.CommandSpec, CommandLine.Model.IAnnotatedElement)
-
options
public java.util.List<CommandLine.Model.OptionSpec> options()
Returns the list of options configured for this command.- Returns:
- an immutable list of options that this command recognizes.
-
positionalParameters
public java.util.List<CommandLine.Model.PositionalParamSpec> positionalParameters()
Returns the list of positional parameters configured for this command.- Returns:
- an immutable list of positional parameters that this command recognizes.
-
argGroups
public java.util.List<CommandLine.Model.ArgGroupSpec> argGroups()
Returns the argument groups in this command.- Returns:
- an immutable list of groups of options and positional parameters in this command
- Since:
- 4.0
-
optionsMap
public java.util.Map<java.lang.String,CommandLine.Model.OptionSpec> optionsMap()
Returns a map of the option names to option spec objects configured for this command.- Returns:
- an immutable map of options that this command recognizes.
-
negatedOptionsMap
public java.util.Map<java.lang.String,CommandLine.Model.OptionSpec> negatedOptionsMap()
Returns a map of the negated option names to option spec objects configured for this command.- Returns:
- an immutable map of negatable options that this command recognizes.
- Since:
- 4.0
-
posixOptionsMap
public java.util.Map<java.lang.Character,CommandLine.Model.OptionSpec> posixOptionsMap()
Returns a map of the short (single character) option names to option spec objects configured for this command.- Returns:
- an immutable map of options that this command recognizes.
-
requiredArgs
public java.util.List<CommandLine.Model.ArgSpec> requiredArgs()
Returns the list of required options and positional parameters configured for this command. This does not include options and positional parameters that are part of a group.- Returns:
- an immutable list of the required options and positional parameters for this command.
-
unmatchedArgsBindings
public java.util.List<CommandLine.Model.UnmatchedArgsBinding> unmatchedArgsBindings()
Returns the list ofUnmatchedArgumentsBindingsconfigured for this command; eachUnmatchedArgsBindingcaptures the arguments that could not be matched to any options or positional parameters.
-
specElements
public java.util.List<CommandLine.Model.IAnnotatedElement> specElements()
Returns the list of program elements annotated with{@literal @}Specconfigured for this command.- Since:
- 4.0
-
parentCommandElements
public java.util.List<CommandLine.Model.IAnnotatedElement> parentCommandElements()
Returns the list of program elements annotated with{@literal @}ParentCommandconfigured for this command.- Since:
- 4.0
-
name
public java.lang.String name()
Returns name of this command. Used in the synopsis line of the help message.DEFAULT_COMMAND_NAMEby default, initialized fromCommandLine.Command.name()if defined.- See Also:
qualifiedName()
-
aliases
public java.lang.String[] aliases()
Returns the alias command names of this subcommand.- Since:
- 3.1
-
names
public java.util.Set<java.lang.String> names()
- Since:
- 3.9
-
args
public java.util.List<CommandLine.Model.ArgSpec> args()
Returns the list of all options and positional parameters configured for this command.- Returns:
- an immutable list of all options and positional parameters for this command.
-
commandMethodParamValues
java.lang.Object[] commandMethodParamValues()
-
qualifiedName
public java.lang.String qualifiedName()
Returns the String to use as the program name in the synopsis line of the help message: this command'sname, preceded by the qualified name of the parent command, if any, separated by a space.- Returns:
DEFAULT_COMMAND_NAMEby default, initialized fromCommandLine.Command.name()and the parent command if defined.- Since:
- 3.0.1
-
qualifiedName
public java.lang.String qualifiedName(java.lang.String separator)
Returns this command's fully qualified name, which is itsname, preceded by the qualified name of the parent command, if this command has a parent command.- Parameters:
separator- the string to put between the names of the commands in the hierarchy- Returns:
DEFAULT_COMMAND_NAMEby default, initialized fromCommandLine.Command.name()and the parent command if any.- Since:
- 3.6
-
version
public java.lang.String[] version()
Returns version information for this command, to print to the console when the user specifies an option to request version help. This is not part of the usage help message.- Returns:
- the version strings generated by the
version providerif one is set, otherwise the version literals
-
versionProvider
public CommandLine.IVersionProvider versionProvider()
Returns the version provider for this command, to generate theversion()strings.- Returns:
- the version provider or
nullif the version strings should be returned from the version literals.
-
helpCommand
public boolean helpCommand()
Returns whether this subcommand is a help command, and required options and positional parameters of the parent command should not be validated.- Returns:
trueif this subcommand is a help command and picocli should not check for missing required options and positional parameters on the parent command- See Also:
CommandLine.Command.helpCommand()
-
exitCodeOnSuccess
public int exitCodeOnSuccess()
Returns exit code for successful termination. 0 by default, may be set programmatically or via theexitCodeOnSuccessannotation.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnUsageHelp
public int exitCodeOnUsageHelp()
Returns exit code for successful termination after printing usage help on user request. 0 by default, may be set programmatically or via theexitCodeOnVersionHelpannotation.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnVersionHelp
public int exitCodeOnVersionHelp()
Returns exit code for successful termination after printing version help on user request. 0 by default, may be set programmatically or via theexitCodeOnUsageHelpannotation.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnInvalidInput
public int exitCodeOnInvalidInput()
Returns exit code for command line usage error. 2 by default, may be set programmatically or via theexitCodeOnInvalidInputannotation.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnExecutionException
public int exitCodeOnExecutionException()
Returns exit code signifying that an exception occurred when invoking the Runnable, Callable or Method user object of a command. 1 by default, may be set programmatically or via theexitCodeOnExecutionExceptionannotation.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
negatableOptionTransformer
public CommandLine.INegatableOptionTransformer negatableOptionTransformer()
Returns theINegatableOptionTransformerused to create the negative form of negatable options.- Since:
- 4.0
- See Also:
CommandLine.Option.negatable()
-
mixinStandardHelpOptions
public boolean mixinStandardHelpOptions()
Returnstrueif the standard help options have been mixed in with this command,falseotherwise.
-
subcommandsRepeatable
public 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.- Since:
- 4.2
- See Also:
CommandLine.Command.subcommandsRepeatable()
-
toString
public java.lang.String toString()
Returns a string representation of this command, used in error messages and trace messages.- Overrides:
toStringin classjava.lang.Object
-
name
public CommandLine.Model.CommandSpec name(java.lang.String name)
Sets the String to use as the program name in the synopsis line of the help message.- Returns:
- this CommandSpec for method chaining
-
aliases
public CommandLine.Model.CommandSpec aliases(java.lang.String... aliases)
Sets the alternative names by which this subcommand is recognized on the command line.- Returns:
- this CommandSpec for method chaining
- Since:
- 3.1
-
defaultValueProvider
public CommandLine.IDefaultValueProvider defaultValueProvider()
Returns the default value provider for this command.- Returns:
- the default value provider or
null - Since:
- 3.6
-
defaultValueProvider
public CommandLine.Model.CommandSpec defaultValueProvider(CommandLine.IDefaultValueProvider defaultValueProvider)
Sets default value provider for this command.- Parameters:
defaultValueProvider- the default value provider to use, ornull.- Returns:
- this CommandSpec for method chaining
- Since:
- 3.6
-
version
public CommandLine.Model.CommandSpec version(java.lang.String... version)
Sets version information literals for this command, to print to the console when the user specifies an option to request version help. Only used if noversionProvideris set.- Returns:
- this CommandSpec for method chaining
-
versionProvider
public CommandLine.Model.CommandSpec versionProvider(CommandLine.IVersionProvider versionProvider)
Sets version provider for this command, to generate theversion()strings.- Parameters:
versionProvider- the version provider to use to generate the version strings, ornullif the version literals should be used.- Returns:
- this CommandSpec for method chaining
-
helpCommand
public CommandLine.Model.CommandSpec helpCommand(boolean newValue)
Sets whether this is a help command and required parameter checking should be suspended.- Returns:
- this CommandSpec for method chaining
- See Also:
CommandLine.Command.helpCommand()
-
exitCodeOnSuccess
public CommandLine.Model.CommandSpec exitCodeOnSuccess(int newValue)
Sets exit code for successful termination. 0 by default.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnUsageHelp
public CommandLine.Model.CommandSpec exitCodeOnUsageHelp(int newValue)
Sets exit code for successful termination after printing usage help on user request. 0 by default.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnVersionHelp
public CommandLine.Model.CommandSpec exitCodeOnVersionHelp(int newValue)
Sets exit code for successful termination after printing version help on user request. 0 by default.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnInvalidInput
public CommandLine.Model.CommandSpec exitCodeOnInvalidInput(int newValue)
Sets exit code for command line usage error. 2 by default.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
exitCodeOnExecutionException
public 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. 1 by default.- Since:
- 4.0
- See Also:
CommandLine.execute(String...)
-
inherited
public boolean inherited()
Returns whether this command is inherited from a parent command.- Since:
- 4.6
- See Also:
CommandLine.Command.scope()
-
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.6
-
scopeType
public 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.- Since:
- 4.6
-
modelTransformer
public CommandLine.IModelTransformer modelTransformer()
Returns the model transformer for this CommandSpec instance.- Since:
- 4.6
-
modelTransformer
public CommandLine.Model.CommandSpec modelTransformer(CommandLine.IModelTransformer modelTransformer)
Sets the model transformer for this CommandSpec instance.- Since:
- 4.6
-
preprocessor
public CommandLine.IParameterPreprocessor preprocessor()
Returns the preprocessor for this CommandSpec instance.- Since:
- 4.6
-
preprocessor
public CommandLine.Model.CommandSpec preprocessor(CommandLine.IParameterPreprocessor preprocessor)
Sets the preprocessor for this CommandSpec instance.- Since:
- 4.6
-
negatableOptionTransformer
public CommandLine.Model.CommandSpec negatableOptionTransformer(CommandLine.INegatableOptionTransformer newValue)
Sets theINegatableOptionTransformerused to create the negative form of negatable options. Note thatoptionsCaseInsensitive()will also change the case sensitivity of negatable options: any customCommandLine.INegatableOptionTransformerthat 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.- Since:
- 4.0
- See Also:
CommandLine.Option.negatable()
-
mixinStandardHelpOptions
public CommandLine.Model.CommandSpec mixinStandardHelpOptions(boolean newValue)
Sets whether the standard help options should be mixed in with this command.- Returns:
- this CommandSpec for method chaining
- See Also:
CommandLine.Command.mixinStandardHelpOptions()
-
subcommandsRepeatable
public 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.- Since:
- 4.2
- See Also:
CommandLine.Command.subcommandsRepeatable()
-
withToString
public CommandLine.Model.CommandSpec withToString(java.lang.String newValue)
Sets the string representation of this command, used in error messages and trace messages.- Parameters:
newValue- the string representation- Returns:
- this CommandSpec for method chaining
-
updateCommandAttributes
public void updateCommandAttributes(CommandLine.Command cmd, CommandLine.IFactory factory)
Updates the following attributes from the specified@Commandannotation: aliases,parser separator, command name, version, help command, version provider, default provider andusage message spec.- Parameters:
cmd- the@Commandannotation to get attribute values fromfactory- factory used to instantiate classes- Since:
- 3.7
-
initName
void initName(java.lang.String value)
-
initHelpCommand
void initHelpCommand(boolean value)
-
initVersion
void initVersion(java.lang.String[] value)
-
initVersionProvider
void initVersionProvider(CommandLine.IVersionProvider value)
-
initDefaultValueProvider
void initDefaultValueProvider(CommandLine.IDefaultValueProvider value)
-
initDefaultValueProvider
void initDefaultValueProvider(java.lang.Class<? extends CommandLine.IDefaultValueProvider> value, CommandLine.IFactory factory)
-
initSubcommandsRepeatable
void initSubcommandsRepeatable(boolean value)
-
initExitCodeOnSuccess
void initExitCodeOnSuccess(int exitCode)
-
initExitCodeOnUsageHelp
void initExitCodeOnUsageHelp(int exitCode)
-
initExitCodeOnVersionHelp
void initExitCodeOnVersionHelp(int exitCode)
-
initExitCodeOnInvalidInput
void initExitCodeOnInvalidInput(int exitCode)
-
initExitCodeOnExecutionException
void initExitCodeOnExecutionException(int exitCode)
-
updateName
void updateName(java.lang.String value)
-
initModelTransformer
void initModelTransformer(CommandLine.IModelTransformer value)
-
updateModelTransformer
void updateModelTransformer(java.lang.Class<? extends CommandLine.IModelTransformer> value, CommandLine.IFactory factory)
-
initPreprocessor
void initPreprocessor(CommandLine.IParameterPreprocessor value)
-
updatePreprocessor
void updatePreprocessor(java.lang.Class<? extends CommandLine.IParameterPreprocessor> value, CommandLine.IFactory factory)
-
updateHelpCommand
void updateHelpCommand(boolean value)
-
updateSubcommandsRepeatable
void updateSubcommandsRepeatable(boolean value)
-
updateAddMethodSubcommands
void updateAddMethodSubcommands(boolean value)
-
updateVersion
void updateVersion(java.lang.String[] value)
-
updateVersionProvider
void updateVersionProvider(java.lang.Class<? extends CommandLine.IVersionProvider> value, CommandLine.IFactory factory)
-
updateExitCodeOnSuccess
void updateExitCodeOnSuccess(int exitCode)
-
updateExitCodeOnUsageHelp
void updateExitCodeOnUsageHelp(int exitCode)
-
updateExitCodeOnVersionHelp
void updateExitCodeOnVersionHelp(int exitCode)
-
updateExitCodeOnInvalidInput
void updateExitCodeOnInvalidInput(int exitCode)
-
updateExitCodeOnExecutionException
void updateExitCodeOnExecutionException(int exitCode)
-
updateScopeType
void updateScopeType(CommandLine.ScopeType scopeType)
-
findOption
public CommandLine.Model.OptionSpec findOption(char shortName)
Returns the option with the specified short name, ornullif no option with that name is defined for this command.
-
findOption
public CommandLine.Model.OptionSpec findOption(java.lang.String name)
Returns the option with the specified name, ornullif no option with that name is defined for this command.- Parameters:
name- used to search the options. May include option name prefix characters or not.
-
findOption
static CommandLine.Model.OptionSpec findOption(char shortName, java.lang.Iterable<CommandLine.Model.OptionSpec> options)
-
findOption
static CommandLine.Model.OptionSpec findOption(java.lang.String name, java.util.List<CommandLine.Model.OptionSpec> options)
-
stripPrefix
static java.lang.String stripPrefix(java.lang.String prefixed)
-
findVisibleOptionNamesWithPrefix
java.util.List<java.lang.String> findVisibleOptionNamesWithPrefix(java.lang.String prefix)
-
resemblesOption
boolean resemblesOption(java.lang.String arg, CommandLine.Tracer tracer)
-
-