GenerateGetopt

Generate the std.getopt method call.

@safe pure nothrow
string
GenerateGetopt
(
alias Options
alias args
)
()

Examples

// Specify The Parameter Structure
struct Options
{
    @Option("threads", "t")
    @Help("Number of threads to use.")
    size_t threads;

    @Option("file")
    @Help("Input files")
    string[] files;
}

Options props;
string[] arg = ["./structopt", "t", "24"];

// Pass in the struct to generate UDA for
auto helpInfo = mixin(GenerateGetopt!(props, arg));
auto expected = [
    GetOption("-t", "--threads", "Number of threads to use.", false),
    GetOption("", "--file", "Input files", false),
    GetOption("-h", "--help", "This help information.", false)
];

import std.algorithm;
assert(helpInfo.options.equal(expected));

Meta