Specifying a required argument to getopt causes `prog --help` to fail with an error saying that the required argument was missing.
Example program:
import std.getopt;
void main(string[] args) {
string filename;
auto helpinfo = getopt(args,
std.getopt.config.required, "filename", "A file to read", &filename,
);
if(helpinfo.helpWanted) {
defaultGetoptPrinter("I am help text", helpinfo.options);
}
}
$ rdmd test.d --help
std.getopt.GetOptException@/usr/include/dmd/phobos/std/getopt.d(572): Required option filenamewas not supplied
----------------
...
(there's also a typo in the error message, but I submitted a pull request to fix it awhile ago and it was accepted)