blob: 1cf0990445ba4d7ce9b293c9a8314d6681da3a35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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 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
|