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)" >> ~/.bashrc
Elvish
echo "eval (E:COMPLETE=elvish your_program | slurp)" >> ~/.elvish/rc.elv
Fish
echo "source (COMPLETE=fish your_program | psub)" >> ~/.config/fish/config.fish
Powershell
$env:COMPLETE = "powershell"
echo "your_program | Out-String | Invoke-Expression" >> $PROFILE
Remove-Item Env:\COMPLETE
Zsh
echo "source <(COMPLETE=zsh your_program)" >> ~/.zshrc
To disable completions, you can set COMPLETE=
or COMPLETE=0
Structs§
- Bash
- Bash completion adapter
- Complete
Env - Environment-activated completions for your CLI
- Elvish
- Elvish completion adapter
- Fish
- Fish completion adapter
- Powershell
- Powershell completion adapter
- Shells
- Collection of shell-specific completers
- Zsh
- Zsh completion adapter
Traits§
- EnvCompleter
- Shell-integration for completions