From 22926ce29e3f8e040ec349401aeb6a77f32eae72 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 4 Mar 2026 21:26:04 +0800 Subject: Initialize Butchunker project structure and policy system --- scripts/sh/comp_butck.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 scripts/sh/comp_butck.sh (limited to 'scripts') 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 -- cgit