Command

Represents a command-line command.

Constructors

this
this(string name)

Constructs a new command with the given name.

Members

Functions

action
Command action(int delegate(ParsedArgs) action)

Sets the action delegate to be executed for this command. The default action is to print help for the command.

add
Command add(Command cmd)

Adds a subcommand.

add
Command add(Option option)

Adds an option.

add
Command add(Flag flag)

Adds a flag.

add
Command add(Argument arg)

Adds an argument.

argument
Command argument(string format, string description, string defaultValue)

Adds an argument from formatted string.

command
Command command(Command cmd)

Adds a subcommand.

description
Command description(string description)

Sets the description of the command

description
string description()

Gets the description of the command

error
void error(string description)

Prints an error message to stderr.

error
noreturn error(string description, int status)

Prints an error message to stderr and exits with status.

findCommand
const(Command) findCommand(string name, const(Command) root)

Searches for a subcommand with the specified name.

name
string name()

Gets the name of the command.

option
Command option(string format, string description, string defaultValue)

Adds an option or flag from formatted string.

printHelp
int printHelp()

Prints help for the command.

usage
string usage(bool colors)

Gets the usage string for this command.

Variables

chain
Command[] chain;

Chain of commands leading to this command.