-
Notifications
You must be signed in to change notification settings - Fork 2
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
Shortcuts for choices #2
Comments
Indeed that would be nice. However, don't you think that use case could be covered by something like the Of course, we have to decide whether we want to be an exact port of Inquirer.js, or if we want more freedom to do our own thing. |
I'm not really a fan of how the implemented "expand". It's far too complicated to use and I think it only makes sense when you have ≥10 options and don't want to render that many lines. But, if you have that many options, do you really want to select them with one letter? (You'll probably want a fuzzy matcher like fzf instead).
That's totally up to you :) Inquirer.js has some really cool stuff (confirm, checkboxes, basic inputs are all done pretty well), but I would probably not copy it as-is. |
I guess that makes sense. Would you suggest extending the current implementation of
Good point. Let's improve where we can :) |
I would try to extend the current list implementation to try and get shortcut names for its items. This way, it's just a matter of "Did I supply a shortcut name?" and not "Oh, now I have to this whole different function". Let's assume we have an Since the current function signature of |
As mentioned in https://github.com/killercup/rustfix/issues/15 it would be nice to be able to use shortcuts to select a specific option.
While currently, the UI looks like
we could just prepend a shortcut key, like this (the second option is selected here):
The behaviour should be that pressing e.g. o results in the same as choosing the second option and pressing enter.
If we want to be really fancy, we could look for the first word beginning with (or just the occurrence of) the shortcut character in the display text and highlight that one (e.g.
A[n]other option
).Implementation-wise, I would add
fn shortcut(&self) -> Option<char> { None }
to theChoice
trait introduced in #1 and implement it for triples(T, V, S) where S: Into<char>
. (Or create a new struct for list items to keep things readable.)The text was updated successfully, but these errors were encountered: