std.getopt
Processing of command line options.
The getopt module implements a getopt function, which adheres to the POSIX syntax for command line options. GNU extensions are supported in the form of long options introduced by a double dash ("--"). Support for bundling of command line options, as was the case with the more traditional single-letter approach, is provided but not enabled by default.
Copyright
Types 5
Thrown on one of the following conditions:
- An unrecognized command-line argument is passed, and
std.getopt.config.passThroughwas not present. - A command-line option was not found, and
std.getopt.config.requiredwas present. - A callback option is missing a value.
Configuration options for getopt.
You can pass them to getopt in any position, except in between an option string and its bound pointer.
The result of the getopt function.
helpWanted is set if the option --help or -h was passed to the option parser.
Information about an option.
string optShortstring optLongstring helpbool requiredFunctions 10
GetoptResult getopt(T...)(ref string[] args, T opts)Parse and remove command line options from a string array.auto getoptTo(R)(string option, string value,
size_t idx, string file = __FILE__, size_t line = __LINE__)void getoptImpl(T...)(ref string[] args, ref configuration cfg,
ref GetoptResult rslt, ref GetOptException excep,
void[][string] visitedLongOpts, void[][string] visitedShortOpts, T opts)bool handleOption(R)(string option, R receiver, ref string[] args,
ref configuration cfg, bool incremental)bool optMatch(string arg, scope string optPattern, ref string value,
configuration cfg) @safevoid defaultGetoptPrinter(string text, Option[] opt) @safeThis function prints the passed `Option`s and text in an aligned manner on `stdout`.void defaultGetoptFormatter(Output)(Output output, string text, Option[] opt, string style = "%*s %*s%*s%s\n")This function writes the passed text and `Option` into an output range in the manner described in the documentation of function `defaultGetoptPrinter`, unless the style option is used.Variables 5
dchar optionCharThe option character (default '-').
Defaults to '-' but it can be assigned to prior to calling getopt.
string endOfOptionsThe string that conventionally marks the end of all options (default '--').
Defaults to "--" but can be assigned to prior to calling getopt. Assigning an empty string to endOfOptions effectively disables it.
dchar assignCharThe assignment character used in options with parameters (default '=').
Defaults to '=' but can be assigned to prior to calling getopt.
string arraySepWhen set to "", parameters to array and associative array receivers are treated as an individual argument. That is, only one argument is appended or inserted per appearance of the option switch. If arraySep is set to something else, then each parameter is first split by the separator, and the individual pieces are treated as arguments to the same option.
Defaults to "" but can be assigned to prior to calling getopt.
autoIncrementChar = '+'