-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathblack.ts
213 lines (210 loc) · 4.92 KB
/
black.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
// https://github.com/psf/black
const blackVersions: Fig.Generator = {
script: ["gh", "release", "list", "--repo", "psf/black"],
cache: {
ttl: 1000 * 60 * 60 * 24 * 2, // 2 days
},
postProcess: (output) => {
if (!output.includes("Latest")) {
return [];
}
return output.split("\n").map((line) => {
return { name: line.split("\t")[0], description: "Version" };
});
},
};
const completionSpec: Fig.Spec = {
name: "black",
description: "Python code formatter",
args: {
name: "file or directory",
template: "filepaths",
isVariadic: true,
},
options: [
{
name: ["--code", "-c"],
description: "Format the code passed in as a string",
args: {
name: "string",
},
},
{
name: ["--line-length", "-l"],
description: "How many characters per line to allow",
args: {
name: "line length",
default: "88",
},
},
{
name: ["--target-version", "-t"],
description: "Python versions that should be supported",
isRepeatable: true,
args: {
name: "python version",
suggestions: [
"py33",
"py34",
"py35",
"py36",
"py37",
"py38",
"py39",
"py310",
],
default: "per-file auto-detection",
},
},
{
name: "--pyi",
description: "Format all input files regardless of file extension",
},
{
name: "--ipynb",
description:
"Format all input files like Jupyter Notebooks regardless of file extension",
},
{
name: "--python-cell-magics",
description: "Add the given magic to the list of known python-magics",
isRepeatable: true,
args: {
name: "python-magic",
suggestions: [
"python",
"python3",
"timeit",
"prun",
"time",
"pypy",
"capture",
],
},
},
{
name: ["--skip-string-normalization", "-S"],
description: "Don't normalize string quotes or prefixes",
},
{
name: ["--skip-magic-trailing-comma", "-C"],
description: "Don't use trailing commas as a reason to split lines",
},
{
name: "--preview",
description: "Enable potentially disruptive style changes",
},
{
name: "--check",
description: "Don't write the files back, just return the status",
},
{
name: "--diff",
description:
"Don't write the files back, just output a diff for each file on stdout",
},
{
name: "--color",
description: "Show colored diff",
exclusiveOn: ["--no-color"],
dependsOn: ["--diff"],
},
{
name: "--no-color",
description: "Show uncolored diff",
exclusiveOn: ["--color"],
dependsOn: ["--diff"],
},
{
name: "--fast",
description: "Skip temporary sanity checks",
exclusiveOn: ["--safe"],
},
{
name: "--safe",
description: "Run temporary sanity checks",
exclusiveOn: ["--fast"],
},
{
name: "--required-version",
description: "Require a specific version of Black",
args: {
name: "version",
generators: blackVersions,
},
},
{
name: "--include",
description:
"Regex that matches files and directories that should be included on recursive searches",
args: {
name: "Regex",
},
},
{
name: "--exclude",
description:
"Regex that matches files and directories that should be excluded on recursive searches",
args: {
name: "Regex",
},
},
{
name: "--extend-exclude",
description: "Additional exlusions",
args: {
name: "Regex",
},
},
{
name: "--force-exclude",
description:
"Exlude matching files and folders even when passed explicitly",
args: {
name: "Regex",
},
},
{
name: "--stdin-filename",
description: "The name of the file when passing it through stdin",
args: {
name: "file",
template: "filepaths",
},
},
{
name: ["--workers", "-W"],
description: "Number of parallel workers",
args: {
name: "integer",
default: "2",
},
},
{
name: ["--quiet", "-q"],
description: "Don't emit non-error messages to stderr",
},
{
name: ["--verbose", "-v"],
description:
"Also emit messages about files that were not changed or were ignored due to exclusion patterns",
},
{
name: "--version",
description: "Show the version",
},
{
name: "--config",
description: "Read configuration from filepath",
args: {
name: "file",
template: "filepaths",
},
},
{
name: ["--help", "-h"],
description: "Show usage information",
},
],
};
export default completionSpec;