Skip to main content

Module completions

Module completions 

Source
Expand description

Shell-completion generation from the live clap definition.

§Why this is written here rather than taken from a crate

clap_complete is the obvious answer and was measured, not assumed: adding it reports 1 unvetted dependencies: clap_complete:4.6.9 missing ["safe-to-deploy"]. This repository’s cargo vet policy runs an exemption ratchet whose count may only decrease, so the crate cannot be added without either a real audit or breaking the gate. The same reasoning retired the roff crate in crate::cmd::man, and the same trade applies: four narrow emitters cost less than the supply-chain review they avoid.

§What cannot drift

Every completion is walked out of crate::cmd::Cli’s own clap::Command. Nothing is transcribed, so a flag the parser gains appears in all four shells by construction, and tests/completions.rs asserts that — as well as feeding each script to the real shell’s syntax checker, since a completion script that fails to parse is worse than none at all: it breaks the user’s prompt on every tab.

§Path arguments

Which options complete filenames is taken from the argument’s value_parser type — PathBuf means a path — rather than from its value_name reading DIR or FILE. A name is a display convention that nothing enforces; the parser type is the property that actually decides how the value is used.

Enums§

Shell
A shell that completions can be generated for.

Functions§

render
Renders a completion script for shell.