@@ -35,6 +35,10 @@ are deliberately limited and rarely added.
35
35
Note that all command-line options listed above can also be configured using a
36
36
` pyproject.toml ` file (more on that below).
37
37
38
+ #### ` -h ` , ` --help `
39
+
40
+ Show available command-line options and exit.
41
+
38
42
#### ` -c ` , ` --code `
39
43
40
44
Format the code passed in as a string.
@@ -109,6 +113,10 @@ useful when piping source on standard input.
109
113
When processing Jupyter Notebooks, add the given magic to the list of known python-
110
114
magics. Useful for formatting cells with custom python magics.
111
115
116
+ #### ` -x, --skip-source-first-line `
117
+
118
+ Skip the first line of the source code.
119
+
112
120
#### ` -S, --skip-string-normalization `
113
121
114
122
By default, _ Black_ uses double quotes for all strings and normalizes string prefixes,
@@ -132,7 +140,7 @@ functionality in the next major release. Read more about
132
140
133
141
#### ` --check `
134
142
135
- Passing ` --check ` will make _ Black_ exit with:
143
+ Don't write the files back, just return the status. _ Black_ will exit with:
136
144
137
145
- code 0 if nothing would change;
138
146
- code 1 if some files would be reformatted; or
@@ -162,8 +170,8 @@ $ echo $?
162
170
163
171
#### ` --diff `
164
172
165
- Passing ` --diff ` will make _ Black _ print out diffs that indicate what changes _ Black_
166
- would've made. They are printed to stdout so capturing them is simple.
173
+ Don't write the files back, just output a diff to indicate what changes _ Black_ would've
174
+ made. They are printed to stdout so capturing them is simple.
167
175
168
176
If you'd like colored diffs, you can enable them with ` --color ` .
169
177
@@ -179,6 +187,10 @@ All done! ✨ 🍰 ✨
179
187
1 file would be reformatted.
180
188
```
181
189
190
+ #### ` --color ` / ` --no-color `
191
+
192
+ Show (or do not show) colored diff. Only applies when ` --diff ` is given.
193
+
182
194
### ` --line-ranges `
183
195
184
196
When specified, _ Black_ will try its best to only format these lines.
@@ -202,10 +214,6 @@ extra lines outside of the ranges when ther are unformatted lines with the exact
202
214
content. It also disables _Black_'s formatting stability check in `--safe` mode.
203
215
```
204
216
205
- #### ` --color ` / ` --no-color `
206
-
207
- Show (or do not show) colored diff. Only applies when ` --diff ` is given.
208
-
209
217
#### ` --fast ` / ` --safe `
210
218
211
219
By default, _ Black_ performs [ an AST safety check] ( labels/ast-changes ) after formatting
@@ -256,7 +264,7 @@ instead of overriding them.
256
264
#### ` --force-exclude `
257
265
258
266
Like ` --exclude ` , but files and directories matching this regex will be excluded even
259
- when they are passed explicitly as arguments. This is useful when invoking _ Black _
267
+ when they are passed explicitly as arguments. This is useful when invoking Black
260
268
programmatically on changed files, such as in a pre-commit hook or editor plugin.
261
269
262
270
#### ` --stdin-filename `
@@ -275,12 +283,12 @@ exclusions, including from `.gitignore` and command line options.
275
283
276
284
When _ Black_ formats multiple files, it may use a process pool to speed up formatting.
277
285
This option controls the number of parallel workers. This can also be specified via the
278
- ` BLACK_NUM_WORKERS ` environment variable.
286
+ ` BLACK_NUM_WORKERS ` environment variable. Defaults to the number of CPUs in the system.
279
287
280
288
#### ` -q ` , ` --quiet `
281
289
282
- Passing ` -q ` / ` --quiet ` will cause _ Black _ to stop emitting all non-critical output.
283
- Error messages will still be emitted (which can silenced by ` 2>/dev/null ` ).
290
+ Stop emitting all non-critical output. Error messages will still be emitted (which can
291
+ silenced by ` 2>/dev/null ` ).
284
292
285
293
``` console
286
294
$ black src/ -q
@@ -289,9 +297,9 @@ error: cannot format src/black_primer/cli.py: Cannot parse: 5:6: mport asyncio
289
297
290
298
#### ` -v ` , ` --verbose `
291
299
292
- Passing ` -v ` / ` --verbose ` will cause _ Black _ to also emit messages about files that
293
- were not changed or were ignored due to exclusion patterns. If _ Black _ is using a
294
- configuration file, a blue message detailing which one it is using will be emitted.
300
+ Emit messages about files that were not changed or were ignored due to exclusion
301
+ patterns. If _ Black _ is using a configuration file, a message detailing which one it is
302
+ using will be emitted.
295
303
296
304
``` console
297
305
$ black src/ -v
@@ -321,10 +329,6 @@ black, 23.11.0
321
329
Read configuration options from a configuration file. See
322
330
[ below] ( #configuration-via-a-file ) for more details on the configuration file.
323
331
324
- #### ` -h ` , ` --help `
325
-
326
- Show available command-line options and exit.
327
-
328
332
### Environment variable options
329
333
330
334
_ Black_ supports the following configuration via environment variables.
@@ -355,7 +359,7 @@ All done! ✨ 🍰 ✨
355
359
use ` --stdin-filename ` . Useful to make sure _ Black_ will respect the ` --force-exclude `
356
360
option on some editors that rely on using stdin.
357
361
358
- You can also pass code as a string using the ` -c ` / ` - -code` option.
362
+ You can also pass code as a string using the ` --code ` option.
359
363
360
364
### Writeback and reporting
361
365
@@ -435,8 +439,7 @@ refers to the path to your home directory. On Windows, this will be something li
435
439
You can also explicitly specify the path to a particular file that you want with
436
440
` --config ` . In this situation _ Black_ will not look for any other file.
437
441
438
- If you're running with ` --verbose ` , you will see a blue message if a file was found and
439
- used.
442
+ If you're running with ` --verbose ` , you will see a message if a file was found and used.
440
443
441
444
Please note ` blackd ` will not use ` pyproject.toml ` configuration.
442
445
0 commit comments