On a real install (.deb / Homebrew) shell completions are installed
automatically. During development you instead build and load them from the
source tree using the helper scripts in scripts/.
The completion scripts are regenerated by build.rs on every cargo build
(into completions/), and the helpers rebuild, copy/source them, and reload
completion in your current shell.
The dynamic value completion (param/log variable names, flash targets, config keys) calls back into
cfcli __complete, so thecfclion yourPATHmust be the build you just made — the helpers puttarget/debugfirst for you.
The script must be sourced (it drops the cached _cfcli function and
re-runs compinit in your current shell):
source scripts/refresh-completions.zshRun it again after any change to the CLI. If you execute it instead of sourcing it, it only does the file prep — open a new terminal afterwards.
Also sourced (registers the completion in your current shell):
source scripts/refresh-completions.bashParam/log completion reads ~/.config/cf-cli/cf-cli-completion.json, which is
written on every successful connection. To test without a Crazyflie, connect
once (e.g. cfcli param list) or seed the file by hand:
mkdir -p ~/.config/cf-cli
cat > ~/.config/cf-cli/cf-cli-completion.json <<'JSON'
{"log":[{"name":"stabilizer.roll"},{"name":"pm.vbat"}],
"param":[{"name":"kalman.resetEstimation","readonly":false},
{"name":"deck.bcLighthouse4","readonly":true}]}
JSONA real connection overwrites this file.
You can also check the data path directly, independent of any shell glue:
cfcli __complete param-names
cfcli __complete log-names stab
cfcli __complete flash-targetsUse the .zsh helper in zsh and the .bash helper in bash. Sourcing the bash
completion in zsh (or vice versa) registers the wrong machinery and produces
errors like compgen: I need arguments / bad output format specification.
The helpers guard against this and refuse to run in the wrong shell; if it
already happened, just open a fresh terminal.