[Issue 11737] New: Allow optional string value for getopt switches
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 13 20:46:24 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11737
Summary: Allow optional string value for getopt switches
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: arttu.h at yandex.com
--- Comment #0 from arttu.h at yandex.com 2013-12-13 20:46:20 PST ---
Say you want a command line switch like --log. This should enable logging to a
predefined file default.log. User should also be able to use --log=somefile.log
to define where things should be logged.
I tried to achieve this with getopt, but couldn't find a way for it. Adding
--log twice to getopt doesn't work as it just throws an exception if the given
value doesn't fit whatever was added first.
Perhaps there are some workarounds for this such as using config.passThrough
and manually handling --log. However, as this is quite common in command-line
parsing, it would be a nice addition to getopt.
One way this could be achieved: allow an option that takes a string value, but
can be used without a value, in which case the string is set to a default
value.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list