I know that the following works already:
---
import std.getopt, std.typecons, std.stdio;
void main()
{
auto args = ["foo", "-u"];
alias U =Flag!"foo";
U flag = U.no;
getopt(args, "u", { flag = U.yes; }, );
flag.writeln;
}
---
https://run.dlang.io/is/46u8Rx
But Flag is such a common type and "built-in" in Phobos, s.t. getopt should really support it.
Comment #1 by robert.schadek — 2024-12-01T16:32:33Z