summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/sh/comp_butck.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/sh/comp_butck.sh b/scripts/sh/comp_butck.sh
new file mode 100644
index 0000000..8cb31f0
--- /dev/null
+++ b/scripts/sh/comp_butck.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+_butck_completion() {
+ local cur prev words cword
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ words=("${COMP_WORDS[@]}")
+ cword=$COMP_CWORD
+
+ if [[ $cur == -* ]]; then
+ return
+ fi
+
+ case "$prev" in
+ -l|--log-level)
+ COMPREPLY=($(compgen -W "trace debug info warn error" -- "$cur"))
+ return
+ ;;
+ -H|--chunk-hash)
+ COMPREPLY=($(compgen -W "blake3 sha256" -- "$cur"))
+ return
+ ;;
+ -o|--output-dir)
+ COMPREPLY=($(compgen -d -- "$cur"))
+ return
+ ;;
+ -O|--output-file)
+ COMPREPLY=($(compgen -f -- "$cur"))
+ return
+ ;;
+ -p|--policy)
+ local policies
+ policies=$(butck policies 2>/dev/null)
+ COMPREPLY=($(compgen -W "$policies" -- "$cur"))
+ return
+ ;;
+ -R|--register)
+ return
+ ;;
+ esac
+
+ if [[ $cword -eq 1 ]]; then
+ COMPREPLY=($(compgen -W "write build state policies" -- "$cur"))
+ fi
+
+ if [[ $cword -ge 2 ]]; then
+ local subcommand="${COMP_WORDS[1]}"
+ case "$subcommand" in
+ "build"|"write")
+ COMPREPLY=($(compgen -f -- "$cur"))
+ ;;
+ esac
+ fi
+}
+
+complete -F _butck_completion butck