Program

Represents a command-line program.

Constructors

this
this(string name)

Constructs a new program with the given name.

Members

Functions

action
Program action(int delegate(ParsedArgs) dg)

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

add
Program add(Command cmd)

Adds a subcommand.

add
Program add(Option option)

Adds an option.

add
Program add(Flag flag)

Adds a flag.

add
Program add(Argument arg)

Adds an argument.

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

Adds an argument from formatted string.

command
Program command(Command cmd)

Adds a subcommand.

description
Program description(string desc)

Sets the description of the command

helpOption
Program helpOption(string format, string description)

Sets the help flag for the program from formatted string and enables getting command help with it.

helpOption
Program helpOption(Flag flag)

Sets the help flag for the program and enables getting command help with it.

helpOption
const(Flag) helpOption()

Gets the help flag for the program.

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

Adds an option or flag from formatted string.

parse
ParsedArgs parse(string[] args)

Gets the parsed arguments.

printVersion
const(int) printVersion()

Prints the version and returns 0.

run
noreturn run(string[] args)

Runs the program with the given arguments.

versionOption
Program versionOption(Flag flag)

Sets the version flag for the program and enables getting the version with it.

versionOption
Program versionOption(string format, string description)

Sets the version flag for the program from formatted string and enables getting the version with it.

versionOption
const(Flag) versionOption()

Gets the version flag for the program.

versionString
Program versionString(string ver)

Sets the version of the program.

versionString
string versionString()

Gets the version of the program.

Inherited Members

From Command

chain
Command[] chain;

Chain of commands leading to this command.

name
string name()

Gets the name of the command.

description
Command description(string description)

Sets the description of the command

description
string description()

Gets the description of the command

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

Searches for a subcommand with the specified name.

add
Command add(Command cmd)

Adds a subcommand.

command
Command command(Command cmd)

Adds a subcommand.

add
Command add(Option option)

Adds an option.

add
Command add(Flag flag)

Adds a flag.

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

Adds an option or flag from formatted string.

add
Command add(Argument arg)

Adds an argument.

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

Adds an argument from formatted string.

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.

usage
string usage(bool colors)

Gets the usage string for this command.

printHelp
int printHelp()

Prints help for 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.