Expand description
Dynamic, Rust-driven shell completions for binaries that use clap.
clap_dyn_complete differs from clap_complete in two ways:
- Supports dynamically generating completion sets at runtime
- e.g:
cargo build -p <TAB>completions that are generated by parsingCargo.tomlat completion-time to return a list of valid crate names - vs.
clap_complete, which can only emit completions for values known ahead-of-time
- e.g:
- Far easier to add support for new shells
- Logic is driven entirely from Rust, so all that’s needed is a small
“shell adapter” script to adapt
clap_dyn_completeoutput to a particular shell completion engine. - vs.
clap_complete, which requires writing a bespoke code-gen backend for every kind of shell!
- Logic is driven entirely from Rust, so all that’s needed is a small
“shell adapter” script to adapt
That said, clap_dyn_complete has one major downside vs. clap_complete:
increased binary size.
clap_complete completions are entirely separate from the binary, whereas
clap_dyn_complete completions call back into binary to drive completions,
requiring the binary to include its own completion engine.
Structs§
- Complete
- A
clap-compatible struct that can be used to generate completions for the current CLI invocation. - RootCtx
- Context for the current CLI invocation.
Enums§
- Shell
- Shell with in-tree completion stub scripts available
Traits§
- Custom
Completer - A custom completer for a particular argument.
- Custom
Completer Factory - A factory for
CustomCompleters.
Functions§
- emit_
completion_ stub - Emits a minimal “shell adapter” script, tailored to the particular bin.