argparse version 0.7.0 - a CLI parsing library
Adam Ruppe
destructionator at gmail.com
Fri Mar 18 21:30:57 UTC 2022
On Friday, 18 March 2022 at 18:21:46 UTC, Anonymouse wrote:
> I use UDAs extensively in my project and I've historically been
> doing the multiple-UDA approach you describe. Upon seeing
> argparse a few months back I started rewriting it to use a
> single UDA, and I found it allowed for a simpler implementation
> (and not the other way around).
>
> The immediate gains boiled down to that I could now pass what
> is essentially a context struct around at CTFE instead of
> keeping track of multiple variables. Default values are also
> much easier to manage with much fewer `hasUDA`s sprinkled
> everywhere.
One approach you might consider is a hybrid too, where you have
the big struct you build out of the individual udas.
So you work on the big one but you do getBig!decl and it loops
through the members of thebig struct and sees if the same-typed
UDAs are on decl. If so, it loads them in, if not, it leaves
default values.
Then the user can write it either way and you always process it
simpler.
More information about the Digitalmars-d-announce
mailing list