Thread overview | |||||
---|---|---|---|---|---|
|
July 19, 2013 [Issue 10674] New: getopt does not work for enum type | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10674 Summary: getopt does not work for enum type Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: ttanjo@gmail.com --- Comment #0 from Tomoya Tanjo <ttanjo@gmail.com> 2013-07-19 07:48:17 PDT --- In the document of std.getopt.getopt it recognizes enum types but the following code does not work in dmd v2.064-devel-de68798 on Linux 64bit. --- import std.getopt; void main() { auto args = ["--color=yes"]; // The following code is in the document of getopt enum Color { no, yes } Color color; // default initialized to Color.no getopt(args, "color", &color); assert(color == Color.yes); // failed! } --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 19, 2013 [Issue 10674] getopt does not work for enum type | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomoya Tanjo | http://d.puremagic.com/issues/show_bug.cgi?id=10674 hsteoh@quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |hsteoh@quickfur.ath.cx Resolution| |INVALID --- Comment #1 from hsteoh@quickfur.ath.cx 2013-07-19 08:01:30 PDT --- The problem is that args[0] is expected to be the program name, so std.getopt does not try to parse it as an option. If you replace the declaration of args with this: auto args = ["program.exe", "--color=yes"]; then the code works as expected. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 20, 2013 [Issue 10674] getopt does not work for enum type | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomoya Tanjo | http://d.puremagic.com/issues/show_bug.cgi?id=10674 --- Comment #2 from Tomoya Tanjo <ttanjo@gmail.com> 2013-07-19 20:38:36 PDT --- Thank you for your comment. After fixing args, I confirmed it works as expected. BTW, > The problem is that args[0] is expected to be the program name, is it described in the document? I did not find it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation