-
-
Notifications
You must be signed in to change notification settings - Fork 119
/
_gojq
43 lines (41 loc) · 2.54 KB
/
_gojq
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
#compdef gojq
_gojq()
{
_arguments -s -S \
'(-r --raw-output --raw-output0 -j --join-output)'{-r,--raw-output}'[output raw strings]' \
'(-r --raw-output -j --join-output)--raw-output0[implies -r with NUL character delimiter]' \
'(-r --raw-output --raw-output0 -j --join-output)'{-j,--join-output}'[implies -r with no newline delimiter]' \
'(-c --compact-output --indent --tab --yaml-output)'{-c,--compact-output}'[output without pretty-printing]' \
'(-c --compact-output --tab --yaml-output)--indent[number of spaces for indentation]:indentation count:(2 4 8)' \
'(-c --compact-output --indent --yaml-output)--tab[use tabs for indentation]' \
'(-c --compact-output --indent --tab )--yaml-output[output in YAML format]' \
'(-C --color-output -M --monochrome-output)'{-C,--color-output}'[output with colors even if piped]' \
'(-C --color-output -M --monochrome-output)'{-M,--monochrome-output}'[output without colors]' \
'(-n --null-input)'{-n,--null-input}'[use null as input value]' \
'(-R --raw-input --stream --yaml-input)'{-R,--raw-input}'[read input as raw strings]' \
'(-R --raw-input --yaml-input)--stream[parse input in stream fashion]' \
'(-R --raw-input --stream )--yaml-input[read input as YAML format]' \
'(-s --slurp)'{-s,--slurp}'[read all inputs into an array]' \
'(-f --from-file 1)'{-f,--from-file}'[load query from file]:filename of jq query:_files' \
'*'{-L,--library-path}'[directory to search modules from]:module directory:_directories' \
'*--arg[set a string value to a variable]:variable name: :string value' \
'*--argjson[set a JSON value to a variable]:variable name: :JSON value' \
'*--slurpfile[set the JSON contents of a file to a variable]:variable name: :JSON file:_files' \
'*--rawfile[set the contents of a file to a variable]:variable name: :file:_files' \
'*--args[consume remaining arguments as positional string values]' \
'*--jsonargs[consume remaining arguments as positional JSON values]' \
'(-e --exit-status)'{-e,--exit-status}'[exit 1 when the last value is false or null]' \
'(- 1 *)'{-v,--version}'[display version information]' \
'(- 1 *)'{-h,--help}'[display help information]' \
'1: :_guard "^-([[:alpha:]0]#|-*)" "jq query"' \
'*: :_gojq_args'
}
_gojq_args() {
if (($words[(I)--args] > $words[(I)--jsonargs])); then
_message 'string value'
elif (($words[(I)--args] < $words[(I)--jsonargs])); then
_message 'JSON value'
else
_arguments '*:input file:_files'
fi
}