mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 14:10:30 +03:00
fix Issue 13315 - std.getopt: implicit help option doesn't work without config.passThrough
This commit is contained in:
parent
66fa95ce19
commit
d51af72d5a
1 changed files with 12 additions and 6 deletions
18
std/getopt.d
18
std/getopt.d
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue