www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14724] New: std.getopt: config.required breaks --help


          Issue ID: 14724
           Summary: std.getopt: config.required breaks --help
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: initrd.gz gmail.com

Specifying a required argument to getopt causes `prog --help` to fail with an
error saying that the required argument was missing.

Example program:

import std.getopt;

void main(string[] args) {
    string filename;

    auto helpinfo = getopt(args,
        std.getopt.config.required, "filename", "A file to read", &filename,

    if(helpinfo.helpWanted) {
        defaultGetoptPrinter("I am help text", helpinfo.options);

$ rdmd test.d --help
std.getopt.GetOptException /usr/include/dmd/phobos/std/getopt.d(572): Required
option filenamewas not supplied

(there's also a typo in the error message, but I submitted a pull request to
fix it awhile ago and it was accepted)

Jun 23 2015