02-Sep-2013 09:32, H. S. Teoh пишет:
On Sat, Aug 31, 2013 at 07:29:42PM -0700, Jonathan M Davis wrote:
On Saturday, August 31, 2013 19:18:11 Andrei Alexandrescu wrote:
I remember sitting next to Kirk McDonald at the D conference in 2007
as he was showing me Python's argparse. I personally found pretty
much any example we could think of more verbose and uglier than
std.getopt.
std.getopt is definitely lacking some nice-to-have features (like
automatically generating --help from the options), but for the most
part, I don't think that it can be improved much without seriously
complicating it. I think that it's about at the limit of what can be
done and still have it be simple, and it works really well for the
most part, so if we haven't hit the sweet spot, we're at least close.
I've toyed with trying to figure out how to improve it, but I think
that doing so cleanly would be very hard.
I've had several people complain to me about std.getopt not
understanding / supporting "standard" command-line syntax. Like '-c5'
vs. '-c 5'. I've also experienced some quirks in how it handles option
parsing, such as being unable to distinguish between '-w' and '--water'
where both are distinct options (the use case is that multiple options
begin with 'w', but one is more common than the others so '-w' is
desirable as a shorthand, but currently std.getopt support for this is
sketchy and unreliable).
Last time I tried (about a year or so ago) I was frustrated with how
rigid and strange it was.
In the end I just rolled back to some hacks like to!int(args[1]) and so
on. At least that was under my control.
--
Dmitry Olshansky