CLIArgs.parse

Parses the base command line arguments

This can be composed with the program argument. For example, consider a program which wants to expose a --version switch, the definition could look like this:

public struct ProgramCLIArgs
{
    public CLIArgs base; // This struct

    public alias base this; // For convenience

    public bool version_; // Program-specific part
}

Then, an application-specific configuration routine would be:

public GetoptResult parse (ref ProgramCLIArgs clargs, ref string[] args)
{
    auto r = clargs.base.parse(args);
    if (r.helpWanted) return r;
    return getopt(
        args,
        "version", "Print the application version, &clargs.version_");
}
struct CLIArgs
GetoptResult
parse
(
ref string[] args
,
bool passThrough = true
)

Parameters

args string[]

The command line args to parse (parsed options will be removed)

passThrough bool

Whether to enable config.passThrough and config.keepEndOfOptions. true by default, to allow composability. If your program doesn't have other arguments, pass false.

Return Value

Type: GetoptResult

The result of calling getopt

Meta