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

Shell auto completion should also auto complete short options #4954

Closed
segevfiner opened this issue Jan 3, 2018 · 1 comment · Fixed by #4956
Closed

Shell auto completion should also auto complete short options #4954

segevfiner opened this issue Jan 3, 2018 · 1 comment · Fixed by #4956
Labels
auto-locked Outdated issues that have been locked by automation C: autocomplete Autocompletion in shells (pip completion) type: enhancement Improvements to functionality

Comments

@segevfiner
Copy link
Contributor

  • Pip version: 9.0.1
  • Python version: 2.7.12
  • Operating system: Ubuntu 16.04

Description:

Pip's shell auto completion doesn't auto complete short options. The relevant code is:

subcommands += [i.get_opt_string() for i in opts
if i.help != optparse.SUPPRESS_HELP]

Which uses: cpython/Lib/optparse.py:752-756 which returns only the long option, if it's defined.

As a further limitation, which I'm not sure is triggered by Pip's auto completion, is that this will only autocomplete the first long option defined for an option that has multiple long options.

If it's acceptable, we can use the _short_opts and _long_opts attributes to calculate the completions so that we get all short and long options. What do you think?

What I've run:

eval "$(pip completion --zsh)"

➜ pip install -<tab>
# You get:
➜ pip install --
# Since -- is unambiguous when no short options are completed.
segevfiner added a commit to segevfiner/pip that referenced this issue Jan 6, 2018
@pradyunsg pradyunsg added type: enhancement Improvements to functionality C: autocomplete Autocompletion in shells (pip completion) labels Jan 19, 2018
@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: autocomplete Autocompletion in shells (pip completion) type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants