#!/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 lspolicy-all 2>/dev/null) COMPREPLY=($(compgen -W "$policies" -- "$cur")) return ;; -R|--register) return ;; esac if [[ $cword -eq 1 ]]; then COMPREPLY=($(compgen -W "write build lspolicy lspolicy-all" -- "$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