Bug 17904 – Enhanced getopt result with passed arguments

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-10-16T19:08:53Z
Last change time
2024-12-01T16:30:56Z
Assigned to
No Owner
Creator
Andre
Moved to GitHub: phobos#10266 →

Comments

Comment #0 by andre — 2017-10-16T19:08:53Z
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.
Comment #1 by robert.schadek — 2024-12-01T16:30:56Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10266 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB