fix Issue 13315 - std.getopt: implicit help option doesn't work without config.passThrough

This commit is contained in:
Nils Boßung 2014-08-18 00:11:13 +02:00
parent 66fa95ce19
commit d51af72d5a

View file

@ -592,16 +592,15 @@ private void getoptImpl(T...)(ref string[] args, ref configuration cfg,
args = args.remove(i + 1);
break;
}
if (!cfg.passThrough)
{
throw new GetOptException("Unrecognized option "~a);
}
if (a == "--help" || a == "-h")
{
rslt.helpWanted = true;
args = args.remove(i + 1);
continue;
}
if (!cfg.passThrough)
{
throw new GetOptException("Unrecognized option "~a);
}
}
@ -1278,6 +1277,13 @@ unittest
assert(!r.helpWanted);
}
unittest // implicit help option without config.passThrough
{
string[] args = ["program", "--help"];
auto r = getopt(args);
assert(r.helpWanted);
}
/** 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