forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathag.ts
457 lines (388 loc) · 11.8 KB
/
ag.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
// To learn more about Fig's autocomplete standard visit: https://fig.io/docs/concepts/cli-skeleton
// The below is a dummy example for git. Make sure to change the file name!
const completionSpec: Fig.Spec = {
name: "ag",
description:
"Recursively search for PATTERN in PATH. Like grep or ack, but faster",
args: [
{
name: "pattern",
isOptional: true,
isVariadic: false,
},
{
name: "path",
isOptional: true,
isVariadic: true,
template: ["filepaths"],
},
],
options: [
{
name: "--ackmate",
description:
"Output results in a format parseable by AckMate https://github.com/protocool/AckMate",
},
{
name: "--affinity",
description: "Set thread affinity (if platform supports it)",
exclusiveOn: ["--noaffinity"],
},
{
name: "--noaffinity",
description: "Don't set thread affinity (if platform supports it)",
exclusiveOn: ["--affinity"],
},
{
name: ["-a", "--all-types"],
description:
"Search all files. This doesn't include hidden files, and doesn't respect any ignore files",
},
{
name: ["-A", "--after"],
description: "Print lines after match",
args: {
name: "LINES",
description: "The amount of lines",
isOptional: true,
default: "2",
},
},
{
name: ["-B", "--before"],
description: "Print lines before match",
args: {
name: "LINES",
description: "The amount of lines",
isOptional: true,
default: "2",
},
},
{
name: "--nobreak",
description:
"Print a newline between matches in different files. Enabled by default",
},
{
name: ["-c", "--count"],
description:
"Only print the number of matches in each file. Note: This is the number of matches, not the number of matching lines. Pipe output to wc -l if you want the number of matching lines",
},
{
name: "--color",
description: "Print color codes in results",
exclusiveOn: ["--nocolor"],
},
{
name: "--nocolor",
description: "Don't print color codes in results",
exclusiveOn: ["--color"],
},
{
name: "--color-line-number",
description: "Color codes for line numbers. Default is 1;33",
},
{
name: "--color-match",
description: "Color codes for result match numbers. Default is 30;43",
},
{
name: "--color-path",
description: "Color codes for path names. Default is 1;32",
},
{ name: "--column", description: "Print column numbers in results" },
{
name: ["-C", "--context"],
description: "Print lines before and after matches",
args: {
name: "LINES",
description: "The amount of lines",
isOptional: true,
default: "2",
},
},
{
name: ["-D", "--debug"],
description:
"Output ridiculous amounts of debugging info. Not useful unless you're actually debugging",
},
{
name: "--depth",
description: "Search up to NUM directories deep, -1 for unlimited",
args: {
name: "NUM",
description: "The depth in directories to search",
isOptional: true,
default: "25",
},
},
{
name: "--filename",
description: "Print file names",
exclusiveOn: ["--nofilename"],
},
{
name: "--nofilename",
description: "Don't print file names",
exclusiveOn: ["--filename"],
},
{
name: ["-f", "--follow"],
description: "Follow symlinks",
exclusiveOn: ["--nofollow"],
},
{
name: "--nofollow",
description: "Don't follow symlinks",
exclusiveOn: ["-f", "--follow"],
},
{
name: ["-F", "--fixed-strings"],
description: "Alias for --literal for compatibility with grep",
},
{
name: "--group",
description:
"Lumps multiple matches in the same file together, and presents them under a single occurrence of the filename",
exclusiveOn: ["--nogroup"],
},
{
name: "--nogroup",
description:
"Refrains from lumping matches in the same file together, and instead places the filename at the start of each match line",
exclusiveOn: ["--group"],
},
{
name: "-g",
description: "Print filenames matching PATTERN",
args: {
name: "PATTERN",
description: "The pattern to look for",
},
},
{
name: ["-G", "--file-search-regex"],
description: "Only search files whose names match PATTERN",
args: {
name: "PATTERN",
description: "The pattern to look for",
},
},
{
name: ["-H", "--heading"],
description: "Print filenames above matching contents",
exclusiveOn: ["--noheading"],
},
{
name: "--noheading",
description: "Don't print filenames above matching contents",
exclusiveOn: ["-H", "--heading"],
},
{
name: "--hidden",
description: "Search hidden files. This option obeys ignored files",
},
{
name: "--ignore",
description:
"Ignore files/directories whose names match this pattern. Literal file and directory names are also allowed",
args: {
name: "PATTERN",
description: "The pattern to look for",
template: ["filepaths", "folders"],
},
},
{
name: "--ignore-dir",
description: "Alias for --ignore for compatibility with ack",
args: {
name: "NAME",
description: "The directory to ignore",
template: ["filepaths", "folders"],
},
},
{ name: ["-i", "--ignore-case"], description: "Match case-insensitively" },
{
name: ["-l", "--files-with-matches"],
description:
"Only print the names of files containing matches, not the matching lines. An empty query will print all files that would be searched",
},
{
name: ["-L", "--files-without-matches"],
description: "Only print the names of files that don't contain matches",
},
{ name: "--list-file-types", description: "See FILE TYPES below" },
{
name: ["-m", "--max-count"],
description:
"Skip the rest of a file after NUM matches. Default is 0, which never skips",
args: {
name: "NUM",
description: "The number of matches to skip after",
isOptional: true,
},
},
{
name: "--mmap",
description:
"Use of memory-mapped I/O. Defaults to true on platforms where mmap() is faster than read(). (All but macOS.)",
exclusiveOn: ["--nommap"],
},
{
name: "--nommap",
description:
"Don't use of memory-mapped I/O. Defaults to true on platforms where mmap() is faster than read(). (All but macOS.)",
exclusiveOn: ["--mmap"],
},
{
name: "--multiline",
description: "Match regexes across newlines",
exclusiveOn: ["--nomultiline"],
},
{
name: "--nomultiline",
description: "Don't match regexes across newlines",
exclusiveOn: ["--multiline"],
},
{
name: ["-n", "--norecurse"],
description: "Don't recurse into directories",
exclusiveOn: ["-r", "--recurse"],
},
{
name: "--numbers",
description: "Print line numbers",
exclusiveOn: ["--nonumbers"],
},
{
name: "--nonumbers",
description: "Don't print line numbers",
exclusiveOn: ["--numbers"],
},
{
name: ["-o", "--only-matching"],
description: "Print only the matching part of the lines",
},
{
name: "--one-device",
description:
"When recursing directories, don't scan dirs that reside on other storage devices. This lets you avoid scanning slow network mounts. This feature is not supported on all platforms",
},
{
name: ["-p", "--path-to-ignore"],
description: "Provide a path to a specific .ignore file",
args: {
name: "STRING",
description: "The path to the ignore file",
template: "filepaths",
},
},
{
name: "--pager",
description:
"Use a pager such as less. Use --nopager to override. This option is also ignored if output is piped to another program",
args: {
name: "COMMAND",
description: "The pager",
suggestions: ["more", "less", "most"],
},
},
{
name: "--parallel",
description:
'Parse the input stream as a search term, not data to search. This is meant to be used with tools such as GNU parallel. For example: echo "foo\nbar\nbaz" | parallel "ag {} ." will run 3 instances of ag, searching the current directory for "foo", "bar", and "baz"',
},
{
name: "--print-long-lines",
description:
"Print matches on very long lines (> 2k characters by default)",
},
{
name: ["--passthrough", "--passthru"],
description:
"When searching a stream, print all lines even if they don't match",
},
{
name: ["-Q", "--literal"],
description:
"Do not parse PATTERN as a regular expression. Try to match it literally",
},
{
name: ["-r", "--recurse"],
description: "Recurse into directories when searching. Default is true",
exclusiveOn: ["-n", "--norecurse"],
},
{
name: ["-s", "--case-sensitive"],
description: "Match case-sensitively",
},
{
name: ["-S", "--smart-case"],
description:
"Match case-sensitively if there are any uppercase letters in PATTERN, case-insensitively otherwise. Enabled by default",
},
{
name: "--search-binary",
description: "Search binary files for matches",
},
{
name: "--silent",
description: "Suppress all log messages, including errors",
},
{
name: "--stats",
description: "Print stats (files scanned, time taken, etc)",
},
{
name: "--stats-only",
description:
"Print stats (files scanned, time taken, etc) and nothing else",
},
{
name: ["-t", "--all-text"],
description: "Search all text files. This doesn't include hidden files",
},
{
name: ["-u", "--unrestricted"],
description:
"Search all files. This ignores .ignore, .gitignore, etc. It searches binary and hidden files as well",
},
{
name: ["-U", "--skip-vcs-ignores"],
description:
"Ignore VCS ignore files (.gitignore, .hgignore), but still use .ignore",
},
{
name: ["-v", "--invert-match"],
description: "Match every line not containing the specified pattern",
},
{ name: ["-V", "--version"], description: "Print version info" },
{
name: "--vimgrep",
description:
"Output results in the same form as Vim's :vimgrep /pattern/g Here is a ~/.vimrc configuration example: set grepprg=ag --vimgrep $* set grepformat=%f:%l:%c:%m Then use :grep to grep for something. Then use :copen, :cn, :cp, etc. to navigate through the matches",
},
{ name: ["-w", "--word-regexp"], description: "Only match whole words" },
{
name: "--workers",
description:
"Use NUM worker threads. Default is the number of CPU cores, with a max of 8",
args: {
name: "NUM",
description: "The NUM of worker threads",
isOptional: true,
},
},
{
name: ["-z", "--search-zip"],
description:
"Search contents of compressed files. Currently, gz and xz are supported. This option requires that ag is built with lzma and zlib",
},
{
name: ["-0", "--null", "--print0"],
description:
"Separate the filenames with \0, rather than \n: this allows xargs -0 <command> to correctly process filenames containing spaces or newlines",
},
],
};
export default completionSpec;