std.getopt

Jens Mueller jens.k.mueller at gmx.de
Sat Jul 16 06:58:35 PDT 2011


Trass3r wrote:
> Why doesn't std.getopt support standard unix style like 'make -j 4'?
> 
> "uint timeout;
> getopt(args, "timeout|t", &timeout);
> To set timeout to 5, use either of the following: --timeout=5,
> --timeout 5, --t=5, --t 5, or -t5. Forms such as -t 5 and -timeout=5
> will be not accepted."
> 
> Also it doesn't make any sense to me that --t=5 and --t 5 is allowed
> in this case.
> I expected the short alias only to be used with a single dash.

I agree. Not supporting -t 5 is no good. std.getopt took its inspiration
from Perl's Getopt::Long (http://perldoc.perl.org/Getopt/Long.html)
which supports it as well.

I'm unsure about --t=5 and --t 5. I don't like them but I don't have to
use them. But without them the rules would be simpler but removing them
may break code. Adding -t 5 is safe I think.
And maybe we enhance the documentation a bit such that more common
choices are given first and less known but still supported later.

If Andrei agrees maybe you or I can create a pull request for -t 5 and
enhancing the documentation regarding -- for short options.

BTW
-timeout=5 is accepted but it shouldn't. I just wrote unittests for all
combinations.

Jens


More information about the Digitalmars-d mailing list