www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12521] New: std.getopt does not conform to documentation

https://d.puremagic.com/issues/show_bug.cgi?id=12521

           Summary: std.getopt does not conform to documentation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jason spashett.com


--- Comment #0 from Jason Spashett <jason spashett.com> 2014-04-04 16:05:36 PDT
---
Either the documentation is incorrect or the implementation is.

The documentation says:

"If the option has a parameter, that must be "stuck" to the option without any
intervening space or "=": "

and

"Forms such as -t 5 and -timeout=5 will be not accepted. "

Does not appear to be true. The form -t 5 is accepted.

Example:

import std.stdio;
import std.getopt;

void main(string[] args)
{
    uint age;
    std.getopt.getopt(args, "a", &age);

    writeln("age = ", age);
    writeln("args = ", args);
}
C:\temp>dmd getopt.d && getopt -a 5000
age = 5000
args = ["getopt"]

Windows XP 32 bit. v2.065 

The implementation seems to work correctly as I regard it, unless there is a
reason why it should be disallowed I think short options need not have thier
parameter immediatly follow the option, and so the documentation should be
adjusted.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 04 2014