On Friday, 10 June 2022 at 14:20:15 UTC, Vladimir Panteleev wrote:
I invoke https://xkcd.com/927/ ! :)
:-D
I tried to improve one of the existing libs but it didn't go well
enough.
Glad you asked! I use an approach similar to the one here, with
commands in a struct. The common arguments are parsed before
invoking the command.
https://github.com/CyberShadow/steamkeyactivator/blob/144d322ecee65f4f536e5fd4141837e51d61a27a/activator.d#L142
When only some commands need to share some arguments, you can
put them in a tuple.
https://github.com/CyberShadow/Digger/blob/7c7dd167aea2214d594bab932ea4e41e5f0a357a/digger.d#L34
Now you have both approaches: parsing into struct with members
and parsing into function arguments. Why do we need two if one is
enough?