What you're trying to do is currently impossible. I filed a bug
(https://issues.dlang.org/show_bug.cgi?id=14525) because what
you're trying to do really should be possible.
import std.stdio : writefln;
import std.getopt;
void main(string[] args)
{
string fname;
try
{
getopt(args, std.getopt.config.required, "file|f", "File
name", &fname);
writefln("Options parsed: fname=%s", fname);
}
catch (GetOptException e)
{
writefln("\nERROR: %s", e.msg);
auto p = ["placeholder"];
auto r = getopt(p, "file|f", "File name", &fname);
defaultGetoptPrinter("Program usage:", r.options);
}
}