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

Reduce duplicated option completions #26

Conversation

bobwhitelock
Copy link
Contributor

Frequently a CLI has options with both short and long identifiers, e.g. -o and --opt. For an interactive CLI such as that generated by click-repl I think it is nicer to just show the long option(s) in these
cases, to avoid cluttering the completions with the same option many times in different forms. This commit does this; note that short options are still shown if there is not a corresponding long option to show
instead.

Note that this PR is based on #25 as it builds on the completion changes made there.

Thanks!

Previously we generated our own completions for available options and
commands, in a similar way to how this was is done in the
`click._bashcomplete` module.

However, this module has had various improvements made to it since this
was originally done. Rather than duplicate similar code here (and have
to do this again in future), this commit changes our completion to
delegate generating the available completions to Click. There is also
additional handling around this to still display relevant help alongside
the completions, where possible.

The end result is that this commit should make click-repl's completion
function as before, except with some additional completions shown where
these are relevant, such as the completion of choices added in
pallets/click#681. Any additional improvements
to Click's completion will also become available to us.
Frequently a CLI has options with both short and long identifiers, e.g.
`-o` and `--opt`. For an interactive CLI such as that generated by
click-repl I think it is nicer to just show the long option(s) in these
cases, to avoid cluttering the completions with the same option many
times in different forms. This commit does this; note that short options
are still shown if there is not a corresponding long option to show
instead.
@decentral1se
Copy link
Contributor

Ah, very cool. I agree that this is a good change 👍

@untitaker
Copy link
Collaborator

@bobwhitelock I'd like to see this merged eventually, but for now I am closing it because #25 has been inactive as well

@untitaker untitaker closed this Jul 29, 2018
@bobwhitelock
Copy link
Contributor Author

@untitaker fair enough in both cases - needed these changes for a project I'm no longer working on, and no longer remember the details of what I was doing, but if I need to work with click-repl again may take another look at these and open new PRs. Thanks 🙂

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

Successfully merging this pull request may close these issues.

None yet

3 participants