-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_gojo
37 lines (35 loc) · 776 Bytes
/
_gojo
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
#compdef gojo
_gojo()
{
_arguments -S -A '-*' \
'-a[creates an array]' \
'(-y)-p[pretty print]' \
'(-p)-y[YAML format output]' \
'(- *)-v[print version]' \
'(- *)-h[print help]' \
'*: :_gojo_args'
}
_gojo_args()
{
local -A messages=(
'@' 'read file contents'
':' 'read json file'
'%' 'base64 of file contents'
)
if compset -P 1 '(#b)(*)='; then
local name=$match[1]
if compset -P '(#b)([@:%])'; then
_arguments "*:${messages[$match[1]]}:_files"
else
_guard '^-*' "value of '$name'"
fi
elif (($words[(I)-a])); then
if compset -P '(#b)([@:%])'; then
_arguments "*:${messages[$match[1]]}:_files"
else
_guard '^-*' 'element of array'
fi
else
_guard '^-*' 'key=value'
fi
}