[Issue 16539] std.getopt should invoke callbacks in the order given on the command line

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 28 18:28:57 UTC 2022


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

--- Comment #6 from kinke <kinke at gmx.net> ---
Well I'm not too keen on fixing it myself, but I have a use case
(mutually-exclusive flags pair) which should make it pretty clear that it's a
serious problem:

```
void main(string[] args) {
    import std.getopt;
    import std.typecons;

    Nullable!bool useGui;
    void handleCliOrGuiMode(string option) {
        useGui = (option == "gui");
    }

    getopt(args, "cli", &handleCliOrGuiMode, "gui", &handleCliOrGuiMode);

    import std.stdio;
    writeln("useGui: ", useGui);
}
```

```
$ dmd -run foo.d --gui --cli
useGui: true
```

--


More information about the Digitalmars-d-bugs mailing list