OptParser

A command line option parser.

Constructors

this
this(cstring[] argv)
this(string[] argv)

Constructs an OptParser object.

Members

Functions

add
void add(bool delegate() parseDg)

Adds a parser delegate.

add
void add(cstring param, ref T out_arg, void delegate() cb = null)

Adds a delegate for parsing an option.

addDefault
void addDefault(void delegate() defaultDg)

Adds a delegate accepting any option.

consume
void consume(size_t n)

Slices off n elements from argv.

hasArgs
bool hasArgs()

Returns true if arguments are available.

parse
bool parse(cstring param, ref cstring out_arg)

Parses a parameter.

parse
bool parse(cstring flag, ref bool out_arg)

Parses a flag.

parseArgs
bool parseArgs()

Parses all arguments.

popArg
cstring popArg()

Returns the first argument and removes it from the list.

printUsageError
void printUsageError()

Prints the usage error message.

Variables

argv
cstring[] argv;

The argument vector.

error
cstring error;

Holds the error message if an error occurred.

missingArgMessage
cstring missingArgMessage;

Missing argument error message.

parseDgs
bool delegate()[] parseDgs;

Option parsing delegates.

usageErrorMessage
cstring usageErrorMessage;

Usage error message.

Meta