Expand description
Runtime helpers for smart shell completions.
These functions run at completion time inside the compiled binary when
the shell calls app --complete --flag <word>. They are never invoked
during normal program execution.
§Dynamic completion protocol
The generated shell scripts use a two-phase strategy:
Static (baked into the script at compile time):
- Flag names, bool flags,
one_ofvalue lists, range hints.
Dynamic (called at completion time):
- Filesystem queries filtered by extension / directory.
- User-supplied
complete = fn_nameproviders.
The shell script calls:
app --complete --flag <current-word>The app detects --complete, dispatches to the right handler, prints
one candidate per line to stdout, then exits 0. The shell captures
that output as the completion list.
Functions§
- complete_
dirs - List only directories matching
prefix. - complete_
files - List all files (no extension filter).
- complete_
files_ from_ glob - Infer allowed extensions from a glob pattern (
"*.csv","*.{rs,toml}") and delegate tocomplete_files_with_ext. - complete_
files_ with_ ext - List files under the directory implied by
prefix, keeping only those whose extension is inexts(case-insensitive, without the dot). - print_
values - Print one completion candidate per line to stdout.
- print_
values_ filtered - Print one completion candidate per line, filtered by
wordprefix.