digitalmars.D.bugs - [Issue 20948] New: std.getopt: Support std.getop.config.positional
- d-bugmail puremagic.com (35/36) Jun 18 2020 https://issues.dlang.org/show_bug.cgi?id=20948
https://issues.dlang.org/show_bug.cgi?id=20948 Issue ID: 20948 Summary: std.getopt: Support std.getop.config.positional Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: andre s-e-a-p.de std.getopt supports optional arguments (starting with --) but does not support mandatory arguments (positional arguments). Please see the very first example how this is solved in python library argparse https://docs.python.org/3/library/argparse.html In D, positional arguments could also be supported using a new config value `positional`: string foo; string bar; getopt(args, std.getopt.config.positional, "foo", &foo, // positional argument "bar", &bar // non positional argument ); You can call the application withmyapp ABC --bar DEFValue ABC would be assigned to string variable `foo`. The string "foo" serves for documentation purposes while calling the getopt help. Supporting positional arguments in getopt would be a lot more convenient and would provide a better user experience (getopt help) instead of having custom parsing/validation logic implemented in each application different. --
Jun 18 2020