dimensionhq / volt

An experimental package management tool for JavaScript. Upto 30x faster installation of dependencies using pre-flattened dependency trees.
https://voltpkg.com
Apache License 2.0
910 stars 26 forks source link

Migrate to clap-derive for cli #38

Closed numToStr closed 2 years ago

numToStr commented 2 years ago

Is your feature request related to a problem? Please describe. Currently, the Volt Cli is built using a builder pattern which is fine but the downside is the subcommand matching is not optimal as it is relying on a string for matching https://github.com/voltpkg/volt/blob/bd7f714f1a648f07036a28f2c69428acd1e851b7/src/main.rs#L37-L74

Describe the solution you'd like Using derive feature of Clap to build the CLI


I would like to contribute to this change. So, I am putting this here to gather feedback before I start working on it :)

suptejas commented 2 years ago

That's a great idea - my concern is: do we lose the opportunity to customize help menus and usage menus?

I vaguely remember trying to implement parsing using structs (structopt) however, I found that there was less customizability and configuration options. Do let me know if things have changed since then / if there's a way of using the derive feature with customizability for help menus and usage menus.

If you're wondering why I'm specific about customizing these menus - it's because I want to display very helpful messages specific to Volt. Yarn, Npm and Pnpm have great CLI's with very helpful menus and multiple usage examples.

numToStr commented 2 years ago

do we lose the opportunity to customize help menus and usage menus?

IIRC, you can still override it.

If you're wondering why I'm specific about customizing these menus - it's because I want to display very helpful messages specific to Volt. Yarn, Npm and Pnpm have great CLI's with very helpful menus and multiple usage examples.

Well the inbuilt help generation of clap is pretty robust with ability to extend it. Also the generated help doc is fully depends on how you structure the CLI. In my experience, I never feel like anything is lacking but still depends on volt use case.

suptejas commented 2 years ago

Perfect, as long as we can override it this would be a great thing to implement

numToStr commented 2 years ago

Great, I'll create a PR soon so that we can talk on designing the new CLI.