Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 15, 2017 [Issue 17327] std.getopt: repeated options unrecognised | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17327 Jon Degenhardt <jrdemail2000-dlang@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jrdemail2000-dlang@yahoo.co | |m --- Comment #1 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> --- I tried to replicate this with the program below. It failed in the described way for the boolean option, but not for the others. If the original author found other cases it would be worth listing them. ==== getopt_repeated_args.d ==== void main(string[] args) { import std.getopt; import std.stdio; int counter; bool flag; int num; void dryrun0() { writeln("dryrun0"); } void dryrun1(string opt) { writefln("dryrun1(%s)", opt); } void dryrun2(string opt, string val) { writefln("dryrun2(%s, %s)", opt, val); } auto r = getopt( args, "c|counter+", "Counter", &counter, "f|flag", "flag", &flag, "n|num", "number", &num, "x|dryrun0", "zero args", &dryrun0, "y|dryrun1", "option is arg", &dryrun1, "z|dryrun2", "option and val are args", &dryrun2, ); if (r.helpWanted) defaultGetoptPrinter("Options:", r.options); else writefln("counter: %d; flag: %s; num: %d", counter, flag, num); return; } ================ ## All work with repeated invocation except the boolean case. $ ./getopt_repeated_args -c -n 5 -c -n 7 counter: 2; flag: false; num: 7 $ ./getopt_repeated_args --dryrun0 --dryrun0 dryrun0 dryrun0 counter: 0; flag: false; num: 0 $ ./getopt_repeated_args -x -x -y -y -z A -z B dryrun0 dryrun0 dryrun1(y|dryrun1) dryrun1(y|dryrun1) dryrun2(z|dryrun2, A) dryrun2(z|dryrun2, B) counter: 0; flag: false; num: 0 ## Single invocation of the boolean option works $ ./getopt_repeated_args -f counter: 0; flag: true; num: 0 $ ./getopt_repeated_args --flag=true counter: 0; flag: true; num: 0 ## Repeated invocation of the boolean option fails $ ./getopt_repeated_args -f -f std.getopt.GetOptException@/Library/D/dmd/src/phobos/std/getopt.d(790): Unrecognized option -f $ ./getopt_repeated_args --flag=true --flag=false std.getopt.GetOptException@/Library/D/dmd/src/phobos/std/getopt.d(790): Unrecognized option --flag=false -- |
April 15, 2017 [Issue 17327] std.getopt: repeated options unrecognised | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17327 --- Comment #2 from novalazy+dlang@gmail.com --- Oops, sorry for the incomplete bug report. Indeed I hit the problem with a boolean option and forgot to check other types. -- |
April 16, 2017 [Issue 17327] std.getopt: repeated options unrecognised | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17327 --- Comment #3 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> --- PR 5334: https://github.com/dlang/phobos/pull/5334 -- |
April 16, 2017 [Issue 17327] std.getopt: repeated options unrecognised | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17327 --- Comment #4 from github-bugzilla@puremagic.com --- Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/c1d49fc4948977239fa4ed8c15b3d318b3e60ca9 Fix issue 17327 - std.getopt: Repeated boolean command option fails. https://github.com/dlang/phobos/commit/684f41b64ee96a35bd9fba3aca95e5cdbf99d09c Fix issue 17327. Review comments: drop continue statement. https://github.com/dlang/phobos/commit/5aad85503a8bfb96dbf357af2758f01dc64cba60 Merge pull request #5334 from jondegenhardt/getopt-repeated-options-fix Fix issue 17327 - std.getopt: Repeated boolean command option fails. merged-on-behalf-of: Steven Schveighoffer <schveiguy@users.noreply.github.com> -- |
April 16, 2017 [Issue 17327] std.getopt: repeated options unrecognised | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17327 github-bugzilla@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED -- |
June 17, 2017 [Issue 17327] std.getopt: repeated options unrecognised | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17327 --- Comment #5 from github-bugzilla@puremagic.com --- Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/c1d49fc4948977239fa4ed8c15b3d318b3e60ca9 Fix issue 17327 - std.getopt: Repeated boolean command option fails. https://github.com/dlang/phobos/commit/684f41b64ee96a35bd9fba3aca95e5cdbf99d09c Fix issue 17327. Review comments: drop continue statement. https://github.com/dlang/phobos/commit/5aad85503a8bfb96dbf357af2758f01dc64cba60 Merge pull request #5334 from jondegenhardt/getopt-repeated-options-fix -- |
January 05, 2018 [Issue 17327] std.getopt: repeated options unrecognised | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17327 --- Comment #6 from github-bugzilla@puremagic.com --- Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/c1d49fc4948977239fa4ed8c15b3d318b3e60ca9 Fix issue 17327 - std.getopt: Repeated boolean command option fails. https://github.com/dlang/phobos/commit/684f41b64ee96a35bd9fba3aca95e5cdbf99d09c Fix issue 17327. Review comments: drop continue statement. https://github.com/dlang/phobos/commit/5aad85503a8bfb96dbf357af2758f01dc64cba60 Merge pull request #5334 from jondegenhardt/getopt-repeated-options-fix -- |
Copyright © 1999-2021 by the D Language Foundation