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: [email protected]
ReportedBy: [email protected]
--- Comment #0 from [email protected] 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: -------