std.getopt suggestion

Jose Armando Garcia jsancio at gmail.com
Fri Sep 30 18:57:47 PDT 2011


On Fri, Sep 30, 2011 at 11:27 AM, Nick Sabalausky <a at a.a> wrote:
> "Jose Armando Garcia" <jsancio at gmail.com> 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!

Just my two cents.


More information about the Digitalmars-d mailing list