std.getopt suggestion

Nick Sabalausky a at a.a
Wed Oct 5 13:24:41 PDT 2011

"Jonathan M Davis" <jmdavisProg at> wrote in message 
news:mailman.23.1317827712.28623.digitalmars-d at
> On Wednesday, October 05, 2011 16:24:32 Jens Mueller wrote:
>> > However, the current way to parametrise getopt is to change the
>> > character for options ('-'), and I belive the string for long option is
>> > twice the character for short option ("--"). I don't think this makes
>> > great sense. We could parametrize a long option string (that we could
>> > set to "-"), and a short option char (that may or may not be
>> > automatically set to longOptionString[0]). But no parametrization on 
>> > the
>> > shortOptionChar and on the longOptionString is fine too. Nobody would
>> > complain the call to getopt could be screwed up by another programmer
>> > modifiying the shortOptionChar behind your back if this could not be
>> > changed in the first place...
>> This can be implemented. But right now I'm trying to figure out whether
>> it's worth it.

FWIW, that would make it possible to parse the command line of programs like 
*ahem* DMD itself.

> Personally, I think that the usage of a single dash with long options is 
> the
> sort of thing that should be discouraged in programs, since it goes 
> against
> how posix programs normally work.

Not all programs are Posix programs, though (for better or worse). Though I 
don't have any real data to back this up, single dash long options seem to 
be common on Windows. And I don't think I've ever seen combined short 
options on Windows software that wasn't a GNU port. Again, FWIW.

More information about the Digitalmars-d mailing list