Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider Inferred Subcommands #980

Open
kbknapp opened this issue Mar 12, 2017 · 3 comments
Open

Consider Inferred Subcommands #980

kbknapp opened this issue Mar 12, 2017 · 3 comments

Comments

@kbknapp
Copy link
Contributor

kbknapp commented Mar 12, 2017

As of clap v2.21 there is a new setting that allows subcommands to be inferred so long as they're not ambiguous. Since rustup makes heavy use of long strings of subcommands this could greatly increase ergonomics.

For instance the following are equivilant:

$ rustup toolchain update stable
$ rustup to up stable

This also completely sidesteps the, "was it toolchain or toolchains?"

The only change that would be needed in the code is adding a line right after this one with the following:

.global_setting(AppSettings::InferSubcommands)

Thoughts?

@brson
Copy link
Contributor

brson commented Mar 16, 2017

Thank you for the suggestions @kbknapp. I will think about it, but don't have an opinion now.

@Diggsey
Copy link
Contributor

Diggsey commented Mar 16, 2017

The problem with this is if people start relying on it in their scripts, or posting the shortened version in answers or blog posts online, then adding new commands becomes a breaking change.

What about interactively suggesting corrections to the correct subcommand instead? eg.

> rustup to up stable
Did you mean `rustup toolchain update stable?` [Y/n]

There would be no non-interactive option, and it only costs an extra return (since Y is the default). It could use fuzzy matching as well.

@kbknapp
Copy link
Contributor Author

kbknapp commented Mar 16, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants