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.
class ref CommandSpec
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.
fun ref add_command(
cmd: CommandSpec box)
: None val ?
Parameters¶
- cmd: CommandSpec box
Returns¶
- None val ?
add_help¶
Adds a standard help option and, optionally command, to a root command.
fun ref add_help(
hname: String val = "help",
descr': String val = "")
: None val ?
Parameters¶
Returns¶
- None val ?
name¶
Returns the name of this command.
fun box name()
: String val
Returns¶
- String val
descr¶
Returns the description for this command.
fun box descr()
: String val
Returns¶
- String val
options¶
Returns a map by name of the named options of this command.
fun box options()
: HashMap[String val, OptionSpec val, HashEq[String val] val] box
Returns¶
- HashMap[String val, OptionSpec val, HashEq[String val] val] box
commands¶
Returns a map by name of the child commands of this command.
fun box commands()
: HashMap[String val, CommandSpec box, HashEq[String val] val] box
Returns¶
- HashMap[String val, CommandSpec box, HashEq[String val] val] box
args¶
Returns an array of the positional arguments of this command.
fun box args()
: Array[ArgSpec val] box
Returns¶
is_leaf¶
fun box is_leaf()
: Bool val
Returns¶
- Bool val
is_parent¶
fun box is_parent()
: Bool val
Returns¶
- Bool val
help_name¶
Returns the name of the help command, which defaults to "help".
fun box help_name()
: String val
Returns¶
- String val
help_string¶
Returns a formated help string for this command and all of its arguments.
fun box help_string()
: String val
Returns¶
- String val