Available on crate feature
unstable-dynamic only.Expand description
COMPLETE=$SHELL <bin> completion integration
See CompleteEnv:
fn cli() -> clap::Command {
// ...
}
fn main() {
CompleteEnv::with_factory(cli)
.complete();
// ... rest of application logic
}To customize completions, see
To source your completions:
WARNING: We recommend re-sourcing your completions on upgrade.
These completions work by generating shell code that calls into your_program while completing.
That interface is unstable and a mismatch between the shell code and your_program may result
in either invalid completions or no completions being generated.
For this reason, we recommend generating the shell code anew on shell startup so that it is
“self-correcting” on shell launch, rather than writing the generated completions to a file.
Bash
echo "source <(COMPLETE=bash your_program)" >> ~/.bashrcElvish
echo "eval (E:COMPLETE=elvish your_program | slurp)" >> ~/.elvish/rc.elvFish
echo "source (COMPLETE=fish your_program | psub)" >> ~/.config/fish/config.fishPowershell
echo "COMPLETE=powershell your_program | Invoke-Expression" >> $PROFILEZsh
echo "source <(COMPLETE=zsh your_program)" >> ~/.zshrcStructs§
- Bash completion adapter
- Environment-activated completions for your CLI
- Elvish completion adapter
- Fish completion adapter
- Powershell completion adapter
- Collection of shell-specific completers
- Zsh completion adapter
Traits§
- Shell-integration for completions