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.toml
at 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_complete
output 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§
- A
clap
-compatible struct that can be used to generate completions for the current CLI invocation. - Context for the current CLI invocation.
Enums§
- Shell with in-tree completion stub scripts available
Traits§
- A custom completer for a particular argument.
- A factory for
CustomCompleter
s.
Functions§
- Emits a minimal “shell adapter” script, tailored to the particular bin.