[Issue 14921] New: getopt throws preventing printing of options
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Aug 14 13:29:33 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14921
Issue ID: 14921
Summary: getopt throws preventing printing of options
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: schveiguy at yahoo.com
std.getopt.getopt can throw. What do you print in this case, since the
mechanism used to print the help is embedded in the GetOptResult that is
returned?
I think there should be a configuration option to embed in the GetOptResult the
error message instead of throwing it.
At the moment, I have an ugly workaround:
void main(string[] args)
{
void callGetOpt(ref string[] a)
{
getoptresult = getopt(a, ...);
}
try
{
callGetOpt(args);
if(getoptresult.helpRequested)
usage(getoptresult);
}
catch(Exception ex)
{
callGetOpt(null); // generate the help anyway
usage(getoptresult); // print usage
}
...
}
--
More information about the Digitalmars-d-bugs
mailing list