Skip to content

Commit

Permalink
Merge pull request #2604 from burner/getopt_trailing_whitespace
Browse files Browse the repository at this point in the history
getopt had some trailing whitespace
  • Loading branch information
WalterBright committed Oct 10, 2014
2 parents 42cd114 + b7e5be9 commit a9f3641
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions std/getopt.d
Expand Up @@ -125,7 +125,7 @@ void main(string[] args)
To set $(D debugging) to $(D false), invoke the program with
$(D --debugging=false).
)
$(LI $(I Numeric options.) If an option is bound to a numeric type, a
number is expected as the next option, or right within the option separated
with an "=" sign:
Expand Down Expand Up @@ -242,7 +242,7 @@ getopt(args, "tune", &tuningParms);
$(LI If the callback doesn't take any arguments, the callback is
invoked whenever the option is seen.
)
$(LI If the callback takes one string argument, the option string
(without the leading dash(es)) is passed to the callback. After that,
the option string is considered handled and removed from the options
Expand All @@ -269,7 +269,7 @@ void main(string[] args)
---------
)
$(LI If the callback takes two string arguments, the option string is
handled as an option with one argument, and parsed accordingly. The
option and its value are passed to the callback. After that, whatever
Expand Down Expand Up @@ -418,7 +418,7 @@ $(D args) after $(D getopt) returns.
$(D Help Information Generation)
If an option string is followed by another string, this string serves as an
description for this option. The function $(D getopt) returns a struct of type
description for this option. The function $(D getopt) returns a struct of type
$(D GetoptResult). This return value contains information about all passed options
as well a bool indicating if information about these options where required by
the passed arguments.
Expand Down Expand Up @@ -449,10 +449,10 @@ unittest

bool foo;
bool bar;
auto rslt = getopt(args, "foo|f" "Some information about foo.", &foo, "bar|b",
auto rslt = getopt(args, "foo|f" "Some information about foo.", &foo, "bar|b",
"Some help message about bar.", &bar);

if (rslt.helpWanted)
if (rslt.helpWanted)
{
defaultGetoptPrinter("Some information about the program.",
rslt.options);
Expand Down Expand Up @@ -487,7 +487,7 @@ enum config {
/** The result of the $(D getoptX) function.
The $(D GetOptDRslt) contains two members. The first member is a boolean with
the name $(D helpWanted). The second member is an array of $(D Option). The
the name $(D helpWanted). The second member is an array of $(D Option). The
array is accessable by the name $(D options).
*/
struct GetoptResult {
Expand All @@ -509,22 +509,22 @@ pure Option splitAndGet(string opt) @trusted nothrow
{
auto sp = split(opt, "|");
Option ret;
if (sp.length > 1)
if (sp.length > 1)
{
ret.optShort = "-" ~ (sp[0].length < sp[1].length ?
ret.optShort = "-" ~ (sp[0].length < sp[1].length ?
sp[0] : sp[1]);
ret.optLong = "--" ~ (sp[0].length > sp[1].length ?
ret.optLong = "--" ~ (sp[0].length > sp[1].length ?
sp[0] : sp[1]);
}
else
}
else
{
ret.optLong = "--" ~ sp[0];
}

return ret;
}

private void getoptImpl(T...)(ref string[] args, ref configuration cfg,
private void getoptImpl(T...)(ref string[] args, ref configuration cfg,
ref GetoptResult rslt, T opts)
{
static if (opts.length)
Expand Down Expand Up @@ -568,7 +568,7 @@ private void getoptImpl(T...)(ref string[] args, ref configuration cfg,

if (cfg.required && !optWasHandled)
{
throw new GetOptException("Required option " ~ option ~
throw new GetOptException("Required option " ~ option ~
"was not supplied");
}
cfg.required = false;
Expand Down Expand Up @@ -1219,7 +1219,7 @@ unittest // same bug as 7693 only for bool
assert(foo);
}

unittest
unittest
{
bool foo;
auto args = ["prog", "--foo"];
Expand All @@ -1243,8 +1243,8 @@ unittest
bool foo;
bool bar;
auto args = ["prog", "-b", "--foo", "-z"];
getopt(args, config.caseInsensitive, config.required, "foo|f" "Some foo",
&foo, config.caseSensitive, "bar|b", "Some bar", &bar,
getopt(args, config.caseInsensitive, config.required, "foo|f" "Some foo",
&foo, config.caseSensitive, "bar|b", "Some bar", &bar,
config.passThrough);
assert(foo);
assert(bar);
Expand All @@ -1256,7 +1256,7 @@ unittest
bool bar;
auto args = ["prog", "-b", "-z"];
assertThrown(getopt(args, config.caseInsensitive, config.required, "foo|f",
"Some foo", &foo, config.caseSensitive, "bar|b", "Some bar", &bar,
"Some foo", &foo, config.caseSensitive, "bar|b", "Some bar", &bar,
config.passThrough));
}

Expand All @@ -1265,8 +1265,8 @@ unittest
bool foo;
bool bar;
auto args = ["prog", "--foo", "-z"];
assertNotThrown(getopt(args, config.caseInsensitive, config.required,
"foo|f", "Some foo", &foo, config.caseSensitive, "bar|b", "Some bar",
assertNotThrown(getopt(args, config.caseInsensitive, config.required,
"foo|f", "Some foo", &foo, config.caseSensitive, "bar|b", "Some bar",
&bar, config.passThrough));
assert(foo);
assert(!bar);
Expand Down Expand Up @@ -1318,12 +1318,12 @@ unittest
assert(args == ["program", "--option"]);
}

/** This function prints the passed $(D Option) and text in an aligned manner.
/** This function prints the passed $(D 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 $(D Option) passed. If a help
message is present it will be printed after the long version of the
message is present it will be printed after the long version of the
$(D Option).
------------
Expand All @@ -1337,15 +1337,15 @@ Params:
text = The text to printed at the beginning of the help output.
opt = The $(D Option) extracted from the $(D getoptX) parameter.
*/
void defaultGetoptPrinter(string text, Option[] opt)
void defaultGetoptPrinter(string text, Option[] opt)
{
import std.stdio : stdout;

defaultGetoptFormatter(stdout.lockingTextWriter(), text, opt);
}

/** This function writes the passed text and $(D Option) into an output range
in the manner, described in the documentation of function
in the manner, described in the documentation of function
$(D defaultGetoptXPrinter).
Params:
Expand All @@ -1360,10 +1360,10 @@ void defaultGetoptFormatter(Output)(Output output, string text, Option[] opt) {

size_t ls, ll;
bool hasRequired = false;
foreach (it; opt)
foreach (it; opt)
{
ls = max(ls, it.optShort.length);
ll = max(ll, it.optLong.length);
ls = max(ls, it.optShort.length);
ll = max(ll, it.optLong.length);

hasRequired = hasRequired || it.required;
}
Expand All @@ -1372,7 +1372,7 @@ void defaultGetoptFormatter(Output)(Output output, string text, Option[] opt) {

string re = " Required: ";

foreach (it; opt)
foreach (it; opt)
{
output.formattedWrite("%*s %*s%*s%s\n", ls, it.optShort, ll, it.optLong,
hasRequired ? re.length : 1, it.required ? re : " ", it.help);
Expand All @@ -1398,7 +1398,7 @@ unittest
assert(helpMsg.indexOf("-h") != -1);
assert(helpMsg.indexOf("--help") != -1);
assert(helpMsg.indexOf("Help") != -1);

string wanted = "Some Text\n-f --foo Help\n-h --help This help "
~ "information.\n";
assert(wanted == helpMsg);
Expand All @@ -1424,8 +1424,8 @@ unittest
assert(helpMsg.indexOf("-h") != -1);
assert(helpMsg.indexOf("--help") != -1);
assert(helpMsg.indexOf("Help") != -1);
string wanted = "Some Text\n-f --foo Required: Help\n-h --help "

string wanted = "Some Text\n-f --foo Required: Help\n-h --help "
" This help information.\n";
assert(wanted == helpMsg, helpMsg ~ wanted);
}

0 comments on commit a9f3641

Please sign in to comment.