std.getopt suggestion

Nick Sabalausky a at a.a
Sat Oct 1 04:47:59 PDT 2011

"Jose Armando Garcia" <jsancio at> wrote in message 
news:mailman.321.1317434277.26225.digitalmars-d at
> On Fri, Sep 30, 2011 at 11:27 AM, Nick Sabalausky <a at a.a> wrote:
>> "Jose Armando Garcia" <jsancio at> wrote in message
>> Are you serious? Don't allow it? Why? What benefit could that possibly
>> provide? It makes perfect sence to think that there may be legitimate 
>> reason
>> to use a commandline parser on something other than the current process's
>> cmd args. Unittesting, for one, just off the top of my head. Other people
>> here have mentioned other uses.
> You can easily unittest my suggestion. Just implement it internally
> using struct/encapsulation etc but don't expose it.
> A large part of an API is about restricting people's option by solving
> a set of use cases. No technology/API is the correct fit for every
> problem. If you want to parse command lines use getopt. If you want to
> parse config files use YAML, XML, etc.
> You don't want to arbitrarily prevent the user from doing something
> but you want to limit the user's possibility to shoot themselves on
> the foot!

Parsing cmd line arguments that didn't come directly from the unmodified 
args passed into main is hardly shooting one's self in the foot.

More information about the Digitalmars-d mailing list