click-completion is a Click extension that provides shell completion for Fish, Bash, Zsh, and PowerShell. It helps users get tab-completion for their Click-based command-line interfaces. The current version is 0.5.2, and as a `click-contrib` library, it typically maintains an active but often lower-cadence release cycle, with updates often aligning with Click's own evolution.
pip install click-completionVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a minimal Click application integrated with `click-completion`. It defines a root group `cli` with two commands, `hello` and `goodbye`. Calling `click_completion.init()` at the start enables the completion functionality for the CLI. To activate completion, you would typically run `python your_app.py --show-completion <shell_type>` and source the output in your shell configuration.
Remove any calls to `click_completion.extra.install()` or similar legacy installation methods. Update your shell's configuration (`.bashrc`, `.zshrc`, etc.) to explicitly source the completion script generated by `your_cli_app --show-completion <shell_type>`.
These functions have no direct replacement. The intended way to use completion is to call `click_completion.init()` in your app and then have users manually generate and source the completion script using the `--show-completion` argument provided by `click-completion`.
Ensure `click_completion.init()` is called early in your Click app's lifecycle. Instruct users to add `source <(your_cli_app --show-completion bash)` (or similar for their shell) to their shell configuration file (e.g., `~/.bashrc`).
Remove all calls to `click_completion.extra` functions. `click-completion` 0.5.0 and later requires manual generation and sourcing of completion scripts.
Review calls to `click_completion.core.startswith`. Ensure you are passing the `prefix` argument as required by the current version's API.
1. Verify `click_completion.init()` is called in your Click application. 2. Ensure the user has added the correct sourcing command to their shell configuration file (e.g., `echo 'source <(my-cli-app --show-completion bash)' >> ~/.bashrc && source ~/.bashrc`).