www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18405] New: std.getopt should support std.typecons.Flag out

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

          Issue ID: 18405
           Summary: std.getopt should support std.typecons.Flag out of the
                    box
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: bootcamp
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

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.

--
Feb 08 2018