First of all it's seems bug in docs:
void main(string[] args)
{
  getopt(
    args,
    "length",  &length,    // numeric
    "file",    &data,      // string
    "verbose", &verbose,   // flag
    "color",   &color);    // enum
  ...
}

with args inside getopt I am getting:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(547): Deprecation: using * o
n an array is deprecated; use *(receiver).ptr instead
C:\D\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(547): Error: cannot modify i
mmutable expression *cast(immutable(char)*)receiver
C:\D\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(548): Deprecation: using * o
n an array is deprecated; use *(receiver).ptr instead

http://dlang.org/phobos/std_getopt.html

But problem that I do not know how handle not existing values:

void main(string[] args)
{
        args.getopt
        (
                "help", &help
        );
}

app.exe -sss
causes crash:
std.getopt.GetOptException@C:\D\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(4
63): Unrecognized option -sss
----------------
0x00453F0E in @safe void std.getopt.getoptImpl!().getoptImpl(ref immutable(char) [][], ref std.getopt.configuration) at C:\D\dmd2\windows\bin\..\..\src\phobos\st
d\getopt.d(463)

Reply via email to