-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathdiff.ts
216 lines (212 loc) · 6.35 KB
/
diff.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
// https://www.gnu.org/software/diffutils
const groupFormatOptions = (names: string[]) =>
names.map<Fig.Option>((name) => ({
name: `--${name}-group-format`,
description: `Similar, but format ${name} input groups with GFTM`,
args: {
name: "GFTM",
description: `%< lines from FILE1
%> lines from FILE2
%= lines common to FILE1 and FILE2
%[-][WIDTH][.[PREC]]{doxX}LETTER printf-style spec for LETTER
LETTERs are as follows for new group, lower case for old group:
F first line number
L last line number
N number of lines = L-F+1
E F-1
M L+1
%% %
%c'C' the single character C
%c'\OOO' the character with octal code OOO`,
},
}));
const lineFormatOptions = (names: string[]) =>
names.map<Fig.Option>((name) => ({
name: `--${name}-line-format`,
description: `Format ${name} input lines with LFTM`,
args: {
name: "LFTM",
description: `%L contents of line
%l contents of line, excluding any trailing newline
%[-][WIDTH][.[PREC]]{doxX}n printf-style spec for input line number
%% %
%c'C' the single character C
%c'\OOO' the character with octal code OOO`,
},
}));
const completionSpec: Fig.Spec = {
name: "diff",
description: "Compare files line by line",
args: {
name: "file",
isVariadic: true,
template: "filepaths",
},
options: [
{
name: ["-i", "--ignore-case"],
description: "Ignore case differences in file contents",
},
{
name: "--ignore-file-name-case",
description: "Ignore case when comparing file names",
exclusiveOn: ["--no-ignore-file-name-case"],
},
{
name: "--no-ignore-file-name-case",
description: "Consider case when comparing file names",
exclusiveOn: ["--ignore-file-name-case"],
},
{
name: ["-E", "--ignore-tab-expansion"],
description: "Ignore changes due to tab expansion",
},
{
name: ["-b", "--ignore-space-change"],
description: "Ignore changes in the amount of white space",
},
{
name: ["-w", "--ignore-all-space"],
description: "Ignore all white space",
},
{
name: ["-B", "--ignore-blank-lines"],
description: "Ignore changes whose lines are all blank",
},
{
name: ["-I", "--ignore-matching-lines"],
description: "Ignore changes whose lines all match RE",
args: {
name: "RE",
},
},
{
name: "--strip-trailing-cr",
description: "Strip trailing carriage return on input",
},
{ name: ["-a", "--text"], description: "Treat all files as text" },
{
name: ["-c", "-C", "--context"],
description: "Output NUM lines of copied context",
args: { name: "NUM", default: "3" },
},
{
name: ["-u", "-U", "--unified"],
description: "Output NUM lines of unified context",
args: { name: "NUM", default: "3" },
},
{
name: "--label",
description: "Use LABEL instead of file name",
args: { name: "LABEL" },
},
{
name: ["-p", "--show-c-function"],
description: "Show which C function each change is in",
},
{
name: ["-F", "--show-function-line"],
description: "Show the most recent line matching RE",
args: { name: "RE" },
},
{
name: ["-q", "--brief"],
description: "Output only whether files differ",
},
{ name: ["-e", "--ed"], description: "Output an ed script" },
{ name: "--normal", description: "Output a normal diff" },
{ name: ["-n", "--rcs"], description: "Output an RCS format diff" },
{ name: ["-y", "--side-by-side"], description: "Output in two columns" },
{
name: ["-W", "--width"],
description: "Output at most NUM (default 130) print columns",
args: { name: "NUM" },
},
{
name: "--left-column",
description: "Output only the left column of common lines",
},
{
name: "--suppress-common-lines",
description: "Do not output common lines",
},
{
name: ["-D", "--ifdef"],
description: "Output merged file to show `#ifdef NAME' diffs",
args: { name: "NAME" },
},
{
name: ["-l", "--paginate"],
description: "Pass the output through `pr' to paginate it",
},
{
name: ["-t", "--expand-tabs"],
description: "Expand tabs to spaces in output",
},
{
name: ["-T", "--initial-tab"],
description: "Make tabs line up by prepending a tab",
},
{
name: ["-r", "--recursive"],
description: "Recursively compare any subdirectories found",
},
{ name: ["-N", "--new-file"], description: "Treat absent files as empty" },
{
name: "--unidirectional-new-file",
description: "Treat absent first files as empty",
},
{
name: ["-s", "--report-identical-files"],
description: "Report when two files are the same",
},
{
name: ["-x", "--exclude"],
description: "Exclude files that match PAT",
args: { name: "PAT" },
},
{
name: ["-X", "--exclude-from"],
description: "Exclude files that match any pattern in FILE",
args: { name: "FILE", template: "filepaths" },
},
{
name: ["-S", "--starting-file"],
description: "Start with FILE when comparing directories",
args: { name: "FILE", template: "filepaths" },
},
{
name: "--from-file",
description: "Compare FILE1 to all operands. FILE1 can be a directory",
args: { name: "FILE1", template: ["filepaths", "folders"] },
},
{
name: "--to-file",
description: "Compare all operands to FILE2. FILE2 can be a directory",
args: { name: "FILE2", template: ["filepaths", "folders"] },
},
{
name: "--horizon-lines",
description: "Keep NUM lines of the common prefix and suffix",
args: { name: "NUM" },
},
{
name: ["-d", "--minimal"],
description: "Try hard to find a smaller set of changes",
},
{
name: "--speed-large-files",
description: "Assume large files and many scattered small changes",
},
{ name: ["-v", "--version"], description: "Output version info" },
{ name: "--help", description: "Show help" },
...groupFormatOptions(["old", "new", "unchanged", "changed"]),
{
name: "--line-format",
description: "Format all input lines with LFMT",
args: { name: "LFTM" },
},
...lineFormatOptions(["old", "new", "unchanged"]),
],
};
export default completionSpec;