structopt

This generative method creates a getopt call based on the attributes assign to a structure.

import structopt;

// 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;
}

void main(string[] args) {
    Options props;

    // Pass in the struct to generate UDA for
    auto helpInfo = mixin(GenerateGetopt!(props, args));

        defaultGetoptPrinter("Options: ",
          helpInfo.options);
        // Output to console:

        //Options:
        //-t --threads Number of threads to use.
        //      --file Input files
        //-h    --help This help information./
}

Modules

attributes
module structopt.attributes

Compile Time attributes for specifying proprites to std.getopt.

Public Imports

structopt.attributes
public import structopt.attributes;
std.getopt
public import std.getopt;
std.traits
public import std.traits;

Members

Aliases

GetOption
alias GetOption = std.getopt.Option

Rename the Option struct of getopt

Option
alias Option = structopt.attributes.Option

Reastablish the name for the struct attributes

Functions

GenerateGetopt
string GenerateGetopt()

Generate the std.getopt method call.

Meta