This patch adds the capability of invoking a program with
./my-program --tune=a=0,b=1,c=2
and initialize an associative array with ["a":0, "b":1, "c":2 ]. Submitted on behalf of Christopher Nicholson-Sauls.
Comment #1 by andrei — 2010-12-04T08:26:22Z
Created attachment 838
Implementation
Comment #2 by andrej.mitrovich — 2013-09-03T09:22:05Z
P.S. currently getopt bails badly on hashes:
-----
import std.getopt;
void main(string[] args)
{
int[string] tune;
getopt(args, &tune, "tune");
}
-----
C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(499): Deprecation: using * on an array is deprecated; use *(receiver).ptr instead
C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\getopt.d(499): Error: cannot modify immutable expression *cast(immutable(char)*)receiver
Comment #3 by andrej.mitrovich — 2013-09-03T09:29:02Z
(In reply to comment #2)
> P.S. currently getopt bails badly on hashes:
>
> -----
> import std.getopt;
>
> void main(string[] args)
> {
> int[string] tune;
> getopt(args, &tune, "tune");
> }
> -----
Actually nevermind, the text argument should come before the address, but this is another area of improvement. I'll open another bug report for this.
Comment #4 by andrej.mitrovich — 2014-03-24T11:54:26Z