forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjq.ts
195 lines (193 loc) · 5.06 KB
/
jq.ts
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
const sharedOptions: Fig.Option[] = [
{
name: "--version",
description: "Output the jq version and exit with zero",
},
{
name: "--seq",
description:
"Use the application/json-seq MIME type scheme for separating JSON texts in jq's input and output",
},
{
name: "--stream",
description:
"Parse the input in streaming fashion, outputting arrays of path and leaf values",
},
{
name: ["--slurp", "-s"],
description:
"Instead of running the filter for each JSON object in the input, read the entire input stream into a large array and run the filter just once",
},
{
name: ["--raw-input", "-R"],
description:
"Don't parse the input as JSON. Instead, each line of text is passed to the filter as a string",
},
{
name: ["--null-input", "-n"],
description:
"Don't read any input at all! Instead, the filter is run once using null as the input",
},
{
name: ["--compact-output", "-c"],
description:
"By default, jq pretty-prints JSON output. Using this option will result in more compact output by instead putting each JSON object on a single line",
},
{
name: "--tab",
description: "Use a tab for each indentation level instead of two spaces",
},
{
name: "--indent",
description: "Use the given number of spaces for indentation",
args: {
name: "n",
description: "No more than 7",
},
},
{
name: ["--color-output", "-C"],
description:
"By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to a pipe or a file using -C",
},
{
name: ["--monochrome-output", "-M"],
description: "Disable color",
},
{
name: ["--ascii-output", "-a"],
description:
"Jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences",
},
{
name: "--unbuffered",
description: "Flush the output after each JSON object is printed",
},
{
name: ["--sort-keys", "-S"],
description:
"Output the fields of each object with the keys in sorted orde",
},
{
name: ["--raw-output", "-r"],
description:
"If the filter's result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes",
},
{
name: ["--join-output", "-j"],
description: "Like -r but jq won't print a newline after each output",
},
{
name: ["-f", "--from-file"],
description: "Read filter from the file rather than from a command line",
args: {
name: "filename",
template: "filepaths",
},
},
{
name: "-L",
description: "Prepend directory to the search list for modules",
args: {
name: "directory",
template: "folders",
},
},
{
name: ["-e", "--exit-status"],
description:
"Sets the exit status of jq to 0 if the last output values was neither false nor null, 1 if the last output value was either false or null, or 4 if no valid result was ever produced",
},
{
name: "--arg",
description:
"This option passes a value to the jq program as a predefined variable",
args: [
{
name: "name",
},
{
name: "value",
},
],
},
{
name: "--argjson",
description:
"This option passes a JSON-encoded value to the jq program as a predefined variable",
args: [
{
name: "name",
},
{
name: "JSON-text",
},
],
},
{
name: "--slurpfile",
description:
"This option reads all the JSON texts in the named file and binds an array of the parsed JSON values to the given global variable",
args: [
{
name: "variable name",
},
{
name: "filename",
template: "filepaths",
},
],
},
{
name: "--rawfile",
description:
"This option reads in the named file and binds its contents to the given global variable",
args: [
{
name: "variable name",
},
{
name: "filename",
template: "filepaths",
},
],
},
{
name: "--args",
description:
"Remaining arguments are positional string arguments. These are available to the jq program as $ARGS.positional[]",
},
{
name: "--jsonargs",
description:
"Remaining arguments are positional JSON text arguments. These are available to the jq program as $ARGS.positional[]",
},
{
name: "--run-tests",
description:
"Runs the tests in the given file or standard input. This must be the last option given and does not honor all preceding options",
args: {
name: "filename",
isOptional: true,
template: "filepaths",
},
},
];
const completionSpec: Fig.Spec = {
name: "jq",
description: "Command-line JSON processor",
options: sharedOptions,
args: [
{
name: "filter",
description: "Must be enclosed in single quotes",
},
{
name: "files",
template: "filepaths",
isOptional: true,
isVariadic: true,
},
],
};
export default completionSpec;