Class CommandSpec
java.lang.Object
com.codename1.cli.CommandSpec
The model of one command: its name, help text, options, positional parameters and subcommands.
The build writes one for every @Command class from its annotations, so an
application normally never constructs one. A command can receive its own
through a field annotated CommandLine.Spec, to print its usage or read the
name it was invoked by.
-
Constructor Summary
ConstructorsConstructorDescriptionCommandSpec(String name, String[] description, String[] version, boolean standardHelpOptions, CommandBinding binding) Creates the model of a command. -
Method Summary
Modifier and TypeMethodDescriptionaddOption(OptionSpec option) Adds an option, and answers this spec.addPositional(PositionalParamSpec positional) Adds a positional parameter, and answers this spec.addSubcommand(CommandSpec sub) Adds a subcommand, and answers this spec.String[]aliases()The other names the command answers to.Sets the other names the command answers to, and answers this spec.binding()The generated code behind this command, or null for a group of subcommands with no body of its own.String[]The lines of help text.name()The name the command is invoked by.options()The options, in declaration order.parent()The enclosing command, or null for the top level.The positional parameters, in declaration order.The name with the names of every enclosing command before it, as the usage line prints it:git remote add.booleanWhether-h/--helpand-V/--versionare recognized.subcommand(String token) The subcommand invoked bytoken, by name or alias, or null.The subcommands, in declaration order.String[]version()The lines--versionprints.
-
Constructor Details
-
CommandSpec
public CommandSpec(String name, String[] description, String[] version, boolean standardHelpOptions, CommandBinding binding) Creates the model of a command.
Parameters
-
name: the name the command is invoked by -
description: the lines of help text printed under the usage line -
version: the lines--versionprints, or an empty array -
standardHelpOptions: whether-h/--helpand-V/--versionare added -
binding: the generated code that creates and runs the command, or null for a group that only holds subcommands
-
-
-
Method Details
-
addOption
Adds an option, and answers this spec. -
addPositional
Adds a positional parameter, and answers this spec. -
addSubcommand
Adds a subcommand, and answers this spec. -
aliases
Sets the other names the command answers to, and answers this spec. -
name
The name the command is invoked by. -
aliases
The other names the command answers to. -
qualifiedName
The name with the names of every enclosing command before it, as the usage line prints it:git remote add. -
description
The lines of help text. -
version
The lines--versionprints. A subcommand with none inherits its parent's. -
standardHelpOptions
public boolean standardHelpOptions()Whether-h/--helpand-V/--versionare recognized. -
options
The options, in declaration order. -
positionals
The positional parameters, in declaration order. -
subcommands
The subcommands, in declaration order. -
parent
The enclosing command, or null for the top level. -
binding
The generated code behind this command, or null for a group of subcommands with no body of its own. -
subcommand
The subcommand invoked bytoken, by name or alias, or null.
-