Fix shell completion for arguments with non-alphanumeric characters#1930
Conversation
|
Please rebase to 8.0.x: |
1d03700 to
ac7caac
Compare
|
Please use |
|
All of them, or just the changelog entries? |
753134c to
f0e6b60
Compare
|
All of them. |
f0e6b60 to
c707a63
Compare
|
Any comments regarding the actual changes? Am I overlooking some cases by assuming that all options begin with a "-"? There might have been a good reason for the alphanumeric check. |
c707a63 to
d8fe64a
Compare
|
Options can start with any non-alpha character, not only |
|
Ah, yes, I should have red https://click.palletsprojects.com/en/8.0.x/options/#other-prefix-characters 🤦. Apologies for that. This makes things a bit more difficult. I can see following choices:
If you agree, I can try to implement the second. |
|
How about just don't support completion of Windows-style options, since that already wasn't supported. |
|
So we would hard-code a set of non-alphanumeric characters that are supported for the shell completion of options? For example One advantages of the 2. approach from my the previous comment: if a command has only arguments and no options, we can offer completion for arguments that start with The most rigorous solution probably would be: if the incomplete string starts with a non-alphanum character, we offer completions for both matching options and arguments. This will however be complex to implement, especially when offering completion for both a path and an option. It's really up to you. As you say in the docs, any prefix other than "-" or "--" for options is discouraged. And the reverse, argument values that start with "-", are quite uncommon. The most probable use case is free string input and shell completion won't be very useful there. |
|
I was thinking |
d8fe64a to
27cdf95
Compare
|
Ok, done. |
6625191 to
91e3880
Compare
This PR fixes shell completion for arguments with non-alphanumeric characters by implementing a less stringent test in
shell_completion._start_of_option().Checklist:
CHANGES.rstsummarizing the change and linking to the issue... versionchanged::entries in any relevant code docs.pre-commithooks and fix any issues.pytestandtox, no tests failed.