-
Notifications
You must be signed in to change notification settings - Fork 892
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
Comments
Thank you for the suggestions @kbknapp. I will think about it, but don't have an opinion now. |
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.
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. |
First, let me preface this with I don't have personal feelings for this
suggestion either way. With CLIs that rely on long strings of subcommands
it can help, but it's totally fine if y'all decide against it :-) I don't
want my being the clap maintainer to come off as a bias *for* this feature,
as it's simply a suggestion to consider.
As for the people relying on shortened versions in scripts and blogs;
that's bad practice in general and I'd be inclined to say breakage stemming
from that shouldn't be a huge concern. Not that it shouldn't be a concern,
but just not a primary worry.
An interactive inference could work too, but I think that's much harder to
implement with chained subcommands unless it's part of clap proper.
Personally though, I try to stay away from any interaction during clap
parsing and would rather have such features built on top (which is back to
being hard :-P). However, it would be technically possible.
Another option is to use [hidden aliases](
https://docs.rs/clap/2.21.1/clap/struct.App.html#method.aliases) for common
shortenings similar to how habitat and diesel do. And I would suggest at a
minimum at least adding both the singular and plural forms of the
appropriate subcommands.
…On Mar 16, 2017 5:45 PM, "Diggory Blake" ***@***.***> wrote:
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.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#980 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGnttjsL1Shn2UFTNUr-4mSitjQPQhSUks5rmbuagaJpZM4MauJq>
.
|
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:
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:
Thoughts?
The text was updated successfully, but these errors were encountered: