ProgramCommands

You can configure a ProgramCommands object with a number of Commands and then use it to parse an list of command line arguments

The object will generate its member variables from the Commands you pass in, for e.g.

auto commands = ProgramCommands!(Command!"one", Command!"two");
commands.one // generated variable
commands.two // generated variable

After you parse command line arguments, the commands that are encountered on the command line become "activated" and can be checked by casting them to a boolean, i.e.

commands.parse(["two"]);
if (commands.one) {} // will be false
if (commands.two) {} // will be true

You can also assign "handler" to a command and use the executeHandlers function to call them for the commands that were activated.

struct ProgramCommands (
Commands...
) if (
Commands.length > 0
) {
enum StartIndex;
enum StartIndex;
Void options;
}

Members

Functions

executeHandlers
void executeHandlers()

If any of the Commands have any handlers specified. Then those will be called in order of appearance on the command line by calling this function

helpText
string helpText()

Returns a string that represents a block of text that can be output to stdout to display a help message

parse
void parse(const string[] args)

Parses the command line arguments according to the set of Commandss that are passed in.

toString
string toString()

Returns a string that is a stringified object of keys and values denoting commands and their values and options (if present)

Variables

options
Commands[0] options;

The ProgramOptions that are associated with this command if any was passed in. If no ProgramOptions where passed as an argument then this aliases to a Void pseudo type.

Meta