Cargo-edit: Switch to Clap

Created on 16 Mar 2018  路  5Comments  路  Source: killercup/cargo-edit

cargo itself recently switched to clap. I know we've had an issue open before about switching away from doctopt and closed it because we wanted to be able to integrate cargo-edit into cargo at some point. Guess we can actually get rid of docopt in good conscience now!

help wanted

Most helpful comment

Is that ok if I鈥檇 like to replace docopt with structopt, rather than clap?

Obviously, structopt has a better API, ~but I'm not sure if this will hinder the plan that being part of cargo in the future.~ structopt::StructOpt can be easily converted to clap::APP.

All 5 comments

I've got this basically implemented, just need to convert the final few tests.

It's essentially a 1:1 port where the only difference is clap enforcing some of the constraints instead of cargo-edit.

The only user facing difference is when using --upgrade=minor it always uses the prefix ^ instead of "". I kind of prefer the explicitness of this, but if you'd prefer to keep "" as the minor prefix it's a simple change.

@kbknapp awesome! I'm fine with having the explicit ^. @bjgill, @ordian, what do you think?

I don't have a strong opinion on that, but would prefer having ^ only if user specifies --upgrade=minor explicitly.

Yeah I should have worded that better, but it sounds like you both picked up on my meaning despite my poor choice of words 馃槣

For others reading this:

Currently in cargo-edit using nothing for the upgrade method (which defaults to minor) uses a blank prefix of "" (empty string) because to cargo it has the same meaning as explicitly using the ^ prefix. Such as 1.2.3 being equivalent to ^1.2.3. However, if the user specified --upgrade=minor on the command line, it used the explicit ^ prefix.

In the port to clap I used the explicit prefix in both cases, when the user uses --upgrade=minor on the command line and when they use nothing and just lets the default case work.

Is that ok if I鈥檇 like to replace docopt with structopt, rather than clap?

Obviously, structopt has a better API, ~but I'm not sure if this will hinder the plan that being part of cargo in the future.~ structopt::StructOpt can be easily converted to clap::APP.

Was this page helpful?
0 / 5 - 0 ratings