genPackageVersion.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.

Members

Classes

GetOptException
class GetOptException

Thrown on one of the following conditions: - An unrecognized command-line argument is passed and std.getopt.config.passThrough was not present.

Enums

config
enum config

Configuration options for getopt.

Functions

defaultGetoptFormatter
void defaultGetoptFormatter(Output output, string text, Option[] opt)

This function writes the passed text and Option into an output range in the manner, described in the documentation of function defaultGetoptPrinter.

defaultGetoptPrinter
void defaultGetoptPrinter(string text, Option[] opt)

This function prints the passed Option and text in an aligned manner.

getopt
GetoptResult getopt(string[] args, T opts)

Parse and remove command line options from an string array.

Manifest constants

autoIncrementChar
enum autoIncrementChar;
Undocumented in source.

Structs

GetoptResult
struct GetoptResult

The result of the getopt function.

Option
struct Option

The result of the getoptHelp function.

Variables

arraySep
string arraySep;

The string used to separate the elements of an array or associative array (default is "" which means the elements are separated by whitespace).

assignChar
dchar assignChar;

The assignment character used in options with parameters (default '=').

endOfOptions
string endOfOptions;

The string that conventionally marks the end of all options (default '--').

optionChar
dchar optionChar;

The option character (default '-').

Meta

Credits

This module and its documentation are inspired by Perl's Getopt::Long module. The syntax of D's getopt is simpler than its Perl counterpart because getopt infers the expected parameter types from the static types of the passed-in pointers.