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
Dynamic Completions: Filter and order completions based on input and importance #5058
Comments
This comment was marked as outdated.
This comment was marked as outdated.
I wonder if we should generalize this to all shells. In particular, I think it is useful to guess the reason and decide how we want to move forward more generally based on that reason. My guess is to not flood the screen, overwhelming the user, but try to provide more targeted information. I think that is a worthwhile cause and should be applied to all shells uniformly. This also gets me thinking of more concrete semantics
Thoughts? |
Another way of putting this is: can we provide a richer experience with the extra semantic information we have? |
Probably, e.g. if someone is currently in the process of rebasing, it would be a good idea to complete We could even go as far as having some form of score users can give options at a later stage, promoting them to be shown earlier. But it is probably a good idea to e.g. not flood the screen with aliases. On long vs short that is probably more difficult to decide, and could be shell dependent to, e.g., match the single dash -> short options behavior in |
At least for a blank screen, I think showing longs for required arguments would be better since that will be more descriptive (in case the descriptions from #5056 aren't sufficient) But for |
yeah, I think preferring short, but falling back to long makes total sense. Also, |
Unless I'm missing something, we've come to a consensus and this is ready to move forward? |
@epage I updated the description |
Made some minor tweaks. Good to go! |
While there are some shell specific behaviors for options, e.g. for
zsh
andfish
:In
zsh
, options are completed if at least one-
is present.In
fish
options are completed if the exact number of dashes is present, i.e. one-
for a short option and two--
for a long option.This had an initial implementation at #5057.
We believe that with the additional knowledge available, clap can do better.
Filtering
On an empty current token, complete:
On a single
-
complete all options, prefer short options where available (this is a candidate for a shell specific (fish
) behavior).On a double
--
complete long options, this would happen either way, so not really a feature. If escaping makes sense (positionals exist), then include just--
In general, aliases are hidden, and only shown if they are the only name of an argument matching the current input.
Sorting
Currently, sorting is probably alphabetic, could be improved to use importance of argument.
Customization
In the future, it could make sense to make both filtering and sorting customizable by the developer.
The text was updated successfully, but these errors were encountered: