Re: argparse version 1.0.0

2022-06-10 Thread Andrey Zherikov via Digitalmars-d-announce

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?





Re: argparse version 1.0.0

2022-06-10 Thread Vladimir Panteleev via Digitalmars-d-announce

On Friday, 10 June 2022 at 14:14:27 UTC, Andrey Zherikov wrote:
On Friday, 10 June 2022 at 09:20:24 UTC, Vladimir Panteleev 
wrote:
Congratulations on the release. Though there's a good number 
of libraries for this task in D already, this solution looks 
very complete.


I looked at them when I started this project and they didn't 
provide complete set of features I was looking for. That was 
the main reason to start this work.


I invoke https://xkcd.com/927/ ! :)

I was wondering if you ran into any strong reasons for 
describing the arguments as a struct, rather than, well, 
function arguments. I have had good success so far with the 
latter, which has the benefit of being succinct:


https://github.com/CyberShadow/btdu/blob/116d190079ca77d61383eb738defa4318d5a1e5f/source/btdu/main.d#L59


This is an interesting approach. I think they are equivalent 
for simple cases but how would you model subcommands with 
common arguments for all of them?


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



Re: argparse version 1.0.0

2022-06-10 Thread Andrey Zherikov via Digitalmars-d-announce

On Friday, 10 June 2022 at 09:20:24 UTC, Vladimir Panteleev wrote:
Congratulations on the release. Though there's a good number of 
libraries for this task in D already, this solution looks very 
complete.


I looked at them when I started this project and they didn't 
provide complete set of features I was looking for. That was the 
main reason to start this work.


I was wondering if you ran into any strong reasons for 
describing the arguments as a struct, rather than, well, 
function arguments. I have had good success so far with the 
latter, which has the benefit of being succinct:


https://github.com/CyberShadow/btdu/blob/116d190079ca77d61383eb738defa4318d5a1e5f/source/btdu/main.d#L59


This is an interesting approach. I think they are equivalent for 
simple cases but how would you model subcommands with common 
arguments for all of them?


Re: argparse version 1.0.0

2022-06-10 Thread Vladimir Panteleev via Digitalmars-d-announce

On Thursday, 9 June 2022 at 19:08:16 UTC, Andrey Zherikov wrote:

Hi everyone,

I'm glad to announce first major version of 
[argparse](https://code.dlang.org/packages/argparse) - a 
library for creating command line interface. It took some time 
to figure out public API of this library and I believe it's 
mature enough for the major version.


Congratulations on the release. Though there's a good number of 
libraries for this task in D already, this solution looks very 
complete.


I was wondering if you ran into any strong reasons for describing 
the arguments as a struct, rather than, well, function arguments. 
I have had good success so far with the latter, which has the 
benefit of being succinct:


https://github.com/CyberShadow/btdu/blob/116d190079ca77d61383eb738defa4318d5a1e5f/source/btdu/main.d#L59