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 with
> myapp ABC --bar DEF
Value 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.
Comment #1 by robert.schadek — 2024-12-01T16:37:02Z