Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class CommandSpec
- Object
- 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.
Constructors
public CommandSpec(String name, String[] description, String[] version, boolean standardHelpOptions, CommandBinding binding) | Creates the model of a command. |
Methods
Inherited methods
Constructor details
CommandSpec
public CommandSpec(String name, String[] description, String[] version, boolean standardHelpOptions, CommandBinding binding)Creates the model of a command.
Parameters
nameString- the name the command is invoked by
descriptionString[]- the lines of help text printed under the usage line
versionString[]- the lines
--versionprints, or an empty array standardHelpOptionsboolean- whether
-h/--helpand-V/--versionare added bindingCommandBinding- the generated code that creates and runs the command, or null for a group that only holds subcommands
Method details
addOption
public CommandSpec addOption(OptionSpec option)Adds an option, and answers this spec.
addPositional
public CommandSpec addPositional(PositionalParamSpec positional)Adds a positional parameter, and answers this spec.
addSubcommand
public CommandSpec addSubcommand(CommandSpec sub)Adds a subcommand, and answers this spec.
aliases
public CommandSpec aliases(String... names)Sets the other names the command answers to, and answers this spec.
name
public String name()The name the command is invoked by.
aliases
public String[] aliases()The other names the command answers to.
qualifiedName
public String qualifiedName()The name with the names of every enclosing command before it, as the
usage line prints it:
git remote add.description
public String[] description()The lines of help text.
version
public String[] version()The lines
--version prints. A subcommand with none inherits its parent’s.standardHelpOptions
public boolean standardHelpOptions()Whether
-h/--help and -V/--version are recognized.options
public List<OptionSpec> options()The options, in declaration order.
positionals
public List<PositionalParamSpec> positionals()The positional parameters, in declaration order.
subcommands
public List<CommandSpec> subcommands()The subcommands, in declaration order.
parent
public CommandSpec parent()The enclosing command, or null for the top level.
binding
public CommandBinding binding()The generated code behind this command, or null for a group of
subcommands with no body of its own.
subcommand
public CommandSpec subcommand(String token)The subcommand invoked by
token, by name or alias, or null.