Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 03, 2013 [Issue 9260] New: getopt should allow setting booleans to false | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9260 Summary: getopt should allow setting booleans to false Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-02 19:12:04 PST --- import std.getopt; void main(string[] args) { bool b; getopt(args, "b", &b); } If you pass: $ rdmd test.d --b=true The '=true' is skipped, as getopt only cares whether '--b' is present. The problem is that this leads to a user thinking that the opposite works: $ rdmd test.d --b=false However 'b' is still true in this case, the '=false' part is discarded. The documentation *does* mention that booleans can only be set to on, however it only uses the syntax '--b' and never mentions '--b=true' (it might be an oversight allowing it). To avoid confusion and avoid code breakage, we should either: 1) Throw when syntax '--b=false' is used, because it has no effect 2) Implement --b=false I think #2 would be the best choice here. The current alternative is to use enums, ala: enum B { no, yes } import std.getopt; void main(string[] args) { B b; getopt(args, "b", &b); } $ rdmd test.d --b=no But there should be no problem implementing #2. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 03, 2013 [Issue 9260] getopt should allow setting booleans to false | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9260 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull AssignedTo|nobody@puremagic.com |andrej.mitrovich@gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-03 10:21:42 PST --- https://github.com/D-Programming-Language/phobos/pull/1050 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 01, 2013 [Issue 9260] getopt should allow setting booleans to false | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9260 hsteoh@quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh@quickfur.ath.cx --- Comment #2 from hsteoh@quickfur.ath.cx 2013-02-28 20:00:41 PST --- Would it be too much to support --no-<flagname> as a synonym for --flag=false? For example, --verbose means --verbose=true, --no-verbose means --verbose=false. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 08, 2013 [Issue 9260] getopt should allow setting booleans to false | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9260 --- Comment #3 from github-bugzilla@puremagic.com 2013-03-08 10:39:02 PST --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/ba8ea757b984a860ef25fd23a63a698543311a3f Fixes Issue 9260 - std.getopt: Implement boolean parsing with optional argument. https://github.com/D-Programming-Language/phobos/commit/2ad62682c4a7a9b269b566689a2ed5dd444f865c Merge pull request #1050 from AndrejMitrovic/Fix9260 Issue 9260 - std.getopt: Implement boolean parsing with optional argument -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 08, 2013 [Issue 9260] getopt should allow setting booleans to false | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9260 Alex Rønne Petersen <alex@lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |alex@lycus.org Resolution| |FIXED -- 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