StructOpt: when clap meet custom derive

Hi!

I present StructOpt, Parse command line argument by defining a struct.

https://github.com/TeXitoi/structopt

Use, make comments, issues, PR!

Feedbacks highly welcome.

10 Likes

This looks great and very intuitive. Thank you!

This seems great, thank you! Do you plan to support subcommands with different options?

Yes: https://github.com/TeXitoi/structopt/issues/1

1 Like

I like it, but I'm afraid the use of Option for optional args - while nice and intuitive - won't scale when you'll want to implement more complex relationships like "this arg is mandatory if this one is there" or "these two are mutually exclusive", which means some relationship specs will sit in types like Option while some others will live elsewhere, probably in #[structopt(...)].

For now there is no problem as you can't call this clap methods.

Then the goal is that the type will set default values that you can override using attributes, so the user will choose if he want an option or a default value in the struct field.

If you have any idea about this problem, and a use case, I'll be very interested.

I used this today and it worked just fine. Thanks @TeXitoi. The obvious thing it was missing was subcommand support.

2 Likes