View source code Display the source code in std/getopt.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.getopt.defaultGetoptPrinter

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

The passed text will be printed first, followed by a newline. Than the short and long version of every option will be printed. The short and long version will be aligned to the longest option of every Option passed. If a help message is present it will be printed after the long version of the Option.

foreach(it; opt)
{
    writefln("%*s %*s %s", lengthOfLongestShortOption, it.optShort,
        lengthOfLongestLongOption, it.optLong, it.help);
}

Prototype

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

Parameters

NameDescription
text The text to printed at the beginning of the help output.
opt The Option extracted from the getopt parameter.

Authors

Andrei Alexandrescu

License

Boost License 1.0.

Comments