aboutsummaryrefslogtreecommitdiffstats
path: root/share/bash-completion
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-01 00:53:00 +0000
committertv <tv@krebsco.de>2026-12-01 01:41:11 +0000
commit0a32f2f57d9e928b7f657decd81c0658eb416e37 (patch)
treefdee382dc832a93b006faaa9448f608f3a03be48 /share/bash-completion
parent30eb9a31ec7e4cf0ef683c86edb28ffc6fa3d54e (diff)
enstate: bash completion
A command until one is given, then the options it takes (each once, but --config and --unset), and for PATH a submission (a directory) or a source list (a file). The package installs it.
Diffstat (limited to 'share/bash-completion')
-rw-r--r--share/bash-completion/completions/enstate64
1 files changed, 64 insertions, 0 deletions
diff --git a/share/bash-completion/completions/enstate b/share/bash-completion/completions/enstate
new file mode 100644
index 0000000..25a8976
--- /dev/null
+++ b/share/bash-completion/completions/enstate
@@ -0,0 +1,64 @@
+# bash completion for enstate: a command until one is given, then the options it
+# takes (each once, but --config and --unset), and for PATH a submission (a
+# directory) or a source list (a file).
+
+_enstate() {
+ local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
+ local commands="--plan --apply --stage --status --materialize --migrate --pack"
+ local settings="--config --unset --state-dir --run-dir --schema --unit --print-config"
+ local i w cmd= path= used=" "
+ # bash splits --option=VALUE into --option, =, VALUE
+ if [ "$prev" = = ] && [ "$COMP_CWORD" -ge 2 ]; then
+ prev=${COMP_WORDS[COMP_CWORD-2]}
+ elif [ "$cur" = = ]; then
+ cur=
+ fi
+ for ((i = 1; i < COMP_CWORD; i++)); do
+ w=${COMP_WORDS[i]}
+ case $w in
+ --plan | --apply | --stage | --status | --materialize | --migrate | --pack)
+ cmd=${w#--} ;;
+ --out | --config | --unset | --state-dir | --run-dir | --schema | --unit)
+ used="$used$w "
+ # its value, written apart or with =
+ if [ "${COMP_WORDS[i+1]}" = = ]; then i=$((i + 2)); else i=$((i + 1)); fi ;;
+ -*) used="$used$w " ;;
+ =) ;;
+ *) path=$w ;;
+ esac
+ done
+ case $prev in
+ --config | --schema) COMPREPLY=($(compgen -f -- "$cur")); return ;;
+ --state-dir | --run-dir | --out) COMPREPLY=($(compgen -d -- "$cur")); return ;;
+ --unset) COMPREPLY=($(compgen -W "state-dir run-dir schema unit" -- "$cur")); return ;;
+ --unit) COMPREPLY=(); return ;;
+ esac
+ local options
+ case $cmd in
+ "") options="$commands -h --help $settings" ;;
+ plan | apply | stage) options="--json $settings" ;;
+ status | materialize) options="--json $settings" ;;
+ migrate) options="--json --dry-run $settings" ;;
+ pack) options="--out $settings" ;;
+ esac
+ local o candidates=
+ for o in $options; do
+ case $o in
+ --config | --unset) ;;
+ *) case $used in *" $o "*) continue ;; esac ;;
+ esac
+ candidates="$candidates $o"
+ done
+ COMPREPLY=()
+ if [ -z "$path" ] && [[ $cur != -* ]]; then
+ case $cmd in
+ plan | apply | stage) COMPREPLY=($(compgen -d -- "$cur")) ;;
+ pack) COMPREPLY=($(compgen -f -- "$cur")) ;;
+ esac
+ fi
+ if [ ${#COMPREPLY[@]} -eq 0 ] || [[ $cur == -* ]]; then
+ COMPREPLY+=($(compgen -W "$candidates" -- "$cur"))
+ fi
+}
+
+complete -o filenames -F _enstate enstate