Make shell completion instruction format Click 8.x and Click 7.x compatible? #826
Unanswered
AndreasBackx
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
To request completions you have to use the variable name
_{CLI_NAME}_COMPLETE
to request a completion instruction, which is in the format{SHELL}_{INSTRUCTION}
where instruction can becomplete
orsource
. Example:Click 8.0 changed this from
{INSTRUCTION}_{SHELL}
to the current{SHELL}_{INSTRUCTION}
. #317 reverted this so it was backwards compatible, which is a good thing. The problem is that when we want to request an instruction and instruct what shell is used, we cannot write code to do this for a binary where we know it's Click but don't know if it's Typer/Click.We have some tooling to make it easy to deploy CLIs in the company with autocomplete. Currently it adheres to the Click 8.0 spec and we have implemented a wrapper around
clap_complete
for Clap CLIs to have the same behaviour (somewhat). I was working on some Clap improvements here and part of this was potentially making Clap adhere to the Click 8.x spec for at least the source instruction. This hasn't been discussed for Clap however so this is not set in stone, definitely as I am not part of the "core maintainers".This all means we can (and potentially future Clap versions might be able to) generate the completion files for Click 8.x and Clap CLIs. Though we cannot support Typer because it did the right thing and kept backwards-compatibility. I feel like it's moot trying to convince Click to change it now, hence why I'm making a post here. Could the implementation be made Click 8.x compatible in addition to Click 7.x compatibility? Then it will be possible for Click, Typer, and Clap CLIs to generate their autocompletion files in the same way.
Operating System
Linux, Windows, macOS, Other
Operating System Details
Unrelated.
Typer Version
0.4.0+
Python Version
Unrelated.
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions