[Issue 17904] New: Enhanced getopt result with passed arguments
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 16 19:08:53 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17904
Issue ID: 17904
Summary: Enhanced getopt result with passed arguments
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: andre at s-e-a-p.de
It would be nice if the result of getopt would have an attribute
"passedArguments" (or another name) which returns a tuple array of type
(string, bool). First value is the passed argument and the seccond value
indicates whether it was listed in the getopt definition.
Example:
auto helpInformation = getopt(
args,
"length", &length, // numeric
"file", &data, // string
"verbose", &verbose, // flag
"color", "Information about this color", &color);
> ./app --file "abc" --anotherOption 15
helpInformation.passedArguments would now contain an array of 2 elements
[tuple("file", true), tuple("anotherOption", false)]
Use case:
If would like to enable following console command
./app set-config --optional-value1 (true|false) --optional-value2 (true-false)
- Either optional-value1 or optinal-value2 or both must be given. Otherwise
error
- Either true or false have to be specified. Otherwise error
I already found a solution but the passedArguments attribute would make the
coding much more readable.
--
More information about the Digitalmars-d-bugs
mailing list