Skip to main content

Module complete

Module complete 

Source
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_of value lists, range hints.

Dynamic (called at completion time):

  • Filesystem queries filtered by extension / directory.
  • User-supplied complete = fn_name providers.

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 to complete_files_with_ext.
complete_files_with_ext
List files under the directory implied by prefix, keeping only those whose extension is in exts (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 word prefix.