CommandSpec¶
CommandSpec describes the specification of a parent or leaf command. Each command has the following attributes:
- a name: a simple string token that identifies the command.
- a description: used in the syntax message.
- a map of options: the valid options for this command.
- an optional help option+command name for help parsing
- one of:
- a Map of child commands.
- an Array of arguments.
Constructors¶
parent¶
Creates a command spec that can accept options and child commands, but not arguments.
new ref parent(
name': String val,
descr': String val = "",
options': Array[OptionSpec val] box = call,
commands': Array[CommandSpec ref] box = call)
: CommandSpec ref^ ?
Parameters¶
- name': String val
- descr': String val = ""
- options': Array[OptionSpec val] box = call
- commands': Array[CommandSpec ref] box = call
Returns¶
- CommandSpec ref^ ?
leaf¶
Creates a command spec that can accept options and arguments, but not child commands.
new ref leaf(
name': String val,
descr': String val = "",
options': Array[OptionSpec val] box = call,
args': Array[ArgSpec val] box = call)
: CommandSpec ref^ ?
Parameters¶
- name': String val
- descr': String val = ""
- options': Array[OptionSpec val] box = call
- args': Array[ArgSpec val] box = call
Returns¶
- CommandSpec ref^ ?
Public Functions¶
add_command¶
Adds an additional child command to this parent command.
Parameters¶
- cmd: CommandSpec box
Returns¶
- None val ?
add_help¶
Adds a standard help option and, optionally command, to a root command.
Parameters¶
Returns¶
- None val ?
name¶
Returns the name of this command.
Returns¶
- String val
descr¶
Returns the description for this command.
Returns¶
- String val
options¶
Returns a map by name of the named options of this command.
Returns¶
- HashMap[String val, OptionSpec val, HashEq[String val] val] box
commands¶
Returns a map by name of the child commands of this command.
Returns¶
- HashMap[String val, CommandSpec box, HashEq[String val] val] box
args¶
Returns an array of the positional arguments of this command.
Returns¶
is_leaf¶
Returns¶
- Bool val
is_parent¶
Returns¶
- Bool val
help_name¶
Returns the name of the help command, which defaults to "help".
Returns¶
- String val
help_string¶
Returns a formated help string for this command and all of its arguments.
Returns¶
- String val