https://issues.dlang.org/show_bug.cgi?id=16604

--- Comment #1 from Eduard Staniloiu <edi33...@gmail.com> ---
There is a more elegant solution.
You can use the passThrough config directive.

>From the docs:
"Passing unrecognized options through:
If an application needs to do its own processing of whichever arguments getopt
did not understand, it can pass the std.getopt.config.passThrough directive to
getopt.

An unrecognized option such as "--baz" will be found untouched in args after
getopt returns."

So, you could do something like this:

        auto helpInformation = getopt(
                args,
                std.getopt.config.passThrough,
                /* Your options here */);

        if (helpInformation.helpWanted || (args.length > 1))
        {
            defaultGetoptPrinter("Some information about the program.",
                    helpInformation.options);
        }

Any mistaken/nonexistent option will be in args, starting with index 1 (at
args[0] you will have the name of your program)

--

Reply via email to