getopt helpWanted

Brian Schott via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 29 15:42:13 PDT 2015


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);
     }
}



More information about the Digitalmars-d-learn mailing list