[Issue 16604] New: [std.getopt] defaultGetoptPrinter can't be used if an exception fires
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Oct 8 00:29:26 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16604
Issue ID: 16604
Summary: [std.getopt] defaultGetoptPrinter can't be used if an
exception fires
Product: D
Version: D2
Hardware: All
URL: http://dlang.org/phobos/
OS: All
Status: NEW
Severity: enhancement
Priority: P3
Component: phobos
Assignee: nobody at puremagic.com
Reporter: kevin at brogan.ca
If an exception is thrown by getopt, the GetoptResults.options array is never
returned. If it isn't returned, then I can't use the defaultGetoptPrinter
function. This makes it impossible to call defaultGetoptPrinter in the event
that a program's user ever makes a mistake.
The GetoptResults.options array is static regardless of what options are passed
to the arguments of the program. It should always be built before any
exceptions fire.
The only way around this is to have an exception show a generic "you made a
mistake calling the program, call 'program --help' to see usage", or to call
getopt with an empty args string and no required parameters to build a second
options array first. Both are klunky.
--
More information about the Digitalmars-d-bugs
mailing list