Getting around the lack of foreach in CTFE

monarch_dodra monarchdodra at gmail.com
Fri Mar 28 08:39:46 PDT 2014


On Friday, 28 March 2014 at 14:42:54 UTC, Colin Grogan wrote:
> Im trying to parse command line args and then build a struct 
> that will, at run-time, hold the data the user passed in via 
> command line args.
> Very similar to Pythons docopt utility -> 
> https://github.com/docopt/docopt
>
> Up till now, I've been using templates to do all of the work, 
> but now that I realise I can do it all with functions I might 
> try that. Then use a mixin template to create the struct with 
> whatever data is required.
>
> Thanks.
> I'm sure I'll be back to bombard ye with questions soon!

Did you try looking into "std.getopt"? It's pretty much the same 
thing. It doesn't quite do the "useage/help" thing automatically 
though (yet). But, IMO, that's trivial to implement.

It's the parsing of arguments you don't want to rewrite. That's 
complicated.


More information about the Digitalmars-d-learn mailing list