https://d.puremagic.com/issues/show_bug.cgi?id=11737
Andrej Mitrovic <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected], | |[email protected] --- Comment #1 from Andrej Mitrovic <[email protected]> 2013-12-15 10:54:11 PST --- I'm thinking of the following, this current code will allow --log=value, but not --log: ----- import std.getopt; import std.stdio; void main(string[] args) { getopt(args, "log", (string option, string value) { // store value here writeln(value); }); } ----- $ rdmd test.d --log=foo > foo $ rdmd test.d --log > object.Exception@C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\getop t.d(486): Missing value for argument --log. So it's meant to catch bugs. However I think we can extend this, and make getopt check whether the value parameter has a default initializer: ----- import std.getopt; import std.stdio; void main(string[] args) { getopt(args, "log", (string option, string value = "bar") // should allow '--log' { // value is either set (e.g. --log=foo), or set to "bar" (--log) writeln(value); }); } ----- That way we don't break code and introduce this new feature. Andrei, thoughts? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
