-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add zsh completion #11409
Add zsh completion #11409
Conversation
src/pip/_internal/cli/cmdoptions.py
Outdated
choices=[ | ||
"any", | ||
"manylinux1_x86_64", | ||
"manylinux1_i386", | ||
"manylinux2014_aarch64", | ||
"win_amd64", | ||
"macosx_10_9_x86_64", | ||
"macosx_11_0_arm64", | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any resource to list all platforms? I just search some one, but it is not all.
And some checks are fail because of similar reason. Such as --implementation fakepy
. fakepy seems not to be one of implementation.
src/pip/_internal/cli/cmdoptions.py
Outdated
@@ -300,18 +300,21 @@ class PipOption(Option): | |||
) | |||
|
|||
|
|||
exists_actions = ["switch", "ignore", "wipe", "backup", "abort"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exists_actions = ["switch", "ignore", "wipe", "backup", "abort"] | |
EXISTS_ACTIONS = { | |
"s": "switch", | |
"i": "ignore", | |
"w": "wipe", | |
"b": "backup", | |
"a": "abort", | |
} |
This maintains the readability, while eliminating the need to add map(lambda x: x[0])
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support this thought. It is more readable.
Only one test failed. What does it means?
|
default=[], | ||
action="append", | ||
metavar="action", | ||
help="Default action when a path already exists: " | ||
"(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.", | ||
", ".join(EXISTS_ACTIONS.values()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the output from:
(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort
to...
switch, ignore, wipe, backup, abort
Given that we don't take "switch" but rather "s" as input here, I'd strongly prefer that we preserve the existing style.
Thanks for filing this PR! I have a few questions:
That's fine -- you can ignore that one, it's a flaky test. :/ |
I know a method: https://github.com/iterative/shtab, it support bash/zsh/tcsh.
However, it only support argparse, not optparse. So before pip support argparse Other methods: click has a different syntax from argparse/optparse,
Right!
Thanks 😄 |
We don’t need an external dependency for this. pip already has logic for providing shell completion from Python, by looking at its own CLI setup: pip/src/pip/_internal/__init__.py Lines 60 to 137 in 80b9524
My question is: Why should we add a separate shell script, instead of extending the existing Python code we have for completions?
Ok, that’s slightly problematic. Our release processes are automated and, ideally, this regeneration is covered as a part of that. I don’t think doing code generation is a good idea though, since we don’t have any automated tests for this generated script, so we won’t know when it’s broken after being regenerated outside of testing it manually, something that increases the amount of work we need to do during a release. We already have a mechanism to provide completions to zsh users, and I’d prefer that we improve it instead of replacing it with something that, while it’s better, represents greater maintenance burden, increases risks of breakage during a release and reduces the likelihood that we’d be able to test this in a portable manner. |
It seems that the original project is to switch external schedule to give up pip's homegrown solution. If so, I think this PR can provide a temporary and enough available solution before this switch. Now the project has changed? And some scheme like shtab is very small, I think it even can be copied to |
Generate zsh completion script by python
Fix #4955
Fix #5364
Fix https://bugs.archlinux.org/task/65349#comment187166
Remove https://github.com/zsh-users/zsh/blob/master/Completion/Unix/Command/_pip
And the old
pip completion --zsh
can be removed.