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

new ref parent(
  name': String val,
  descr': String val = seq,
  options': Array[OptionSpec val] box = seq,
  commands': Array[CommandSpec ref] box = seq)
: CommandSpec ref^ ?

Parameters

Returns


leaf

new ref leaf(
  name': String val,
  descr': String val = seq,
  options': Array[OptionSpec val] box = seq,
  args': Array[ArgSpec val] box = seq)
: CommandSpec ref^ ?

Parameters

Returns


Public Functions

add_command

Adds an additional child command to this parent command.

fun ref add_command(
  cmd: CommandSpec box)
: None val ?

Parameters

Returns


add_help

Adds a standard help option and, optionally command, to a root command.

fun ref add_help(
  hname: String val = seq)
: None val ?

Parameters

Returns


name

Returns the name of this command.

fun box name()
: String val

Returns


descr

Returns the description for this command.

fun box descr()
: String val

Returns


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


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


args

Returns an array of the positional arguments of this command.

fun box args()
: Array[ArgSpec val] box

Returns


help_name

Returns the name of the help command, which defaults to "help".

fun box help_name()
: String val

Returns


help_string

Returns a formated help string for this command and all of its arguments.

fun box help_string()
: String val

Returns


Private Functions

_assertName

fun tag _assertName(
  nm: String val)
: String val ?

Parameters

Returns