CommandSpec

[Source]

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

[Source]

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

Returns

leaf

[Source]

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

Returns

Public Functions

add_command

[Source]

Adds an additional child command to this parent command.

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

Parameters

Returns

add_help

[Source]

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

name

[Source]

Returns the name of this command.

fun box name()
: String val

Returns

descr

[Source]

Returns the description for this command.

fun box descr()
: String val

Returns

options

[Source]

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

[Source]

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

[Source]

Returns an array of the positional arguments of this command.

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

Returns

is_leaf

[Source]

fun box is_leaf()
: Bool val

Returns

is_parent

[Source]

fun box is_parent()
: Bool val

Returns

help_name

[Source]

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

fun box help_name()
: String val

Returns

help_string

[Source]

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

fun box help_string()
: String val

Returns

© 2016-2020, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/cli-CommandSpec