On 19-Aug-12 18:45, David wrote:
Am 19.08.2012 16:36, schrieb bearophile:
David:

Actually, that's why I want that trait :)

But in practice, as your command line programs get a little more
complex, docopt is not enough, you need normal programming with things
like argparse.

So maybe a mix of the two ideas is better, to write most stuff in the
docstring, and then refine its semantics below with normal code.

Bye,
bearophile

I am not writing an actual argparsing-library, I thought of starting
one, but then I realized, I don't have the time to do something amazing
like argparse, so I decided to go with a less complex and heavily CTFE'd
version. It looks like that:

struct AppArguments {
     string username;
     Alias!("username") u;

     string password;
     Alias!("password") p;

     bool credentials;
     Alias!("credentials") c;

     uint width = 1024;
     uint height = 800;

     string host;
     Alias!("host") h;
     ushort port = 25565;

     bool no_snoop = false;
}

void main() {
     auto args = get_options!AppArguments();
}

I added a default --help function to it, if there is no "help" member
declared in AppArguments, but I realized ... --help without messages is
kinda pointless ...

What's wrong with std.getopt? I thought there was some movement to improve it (including auto-generating usage messages).

--
Olshansky Dmitry

Reply via email to