You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/en/guide/cli/fmt.mdx
+64-11Lines changed: 64 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The `rs fmt` command formats files or checks whether they are formatted. For det
8
8
rs fmt [options] [files/globs...]
9
9
```
10
10
11
-
Pass files, directories, or glob patterns to choose what to format. When no paths are provided, `rs fmt` formats the current directory.
11
+
Pass files, directories, or glob patterns to choose what to format. When no paths are provided, `rs fmt` formats the current directory. See [Formatting scope](../formatting#formatting-scope) for path resolution and ignore rules.
|`--write`| Write formatted files in place. This is the default mode. |
37
-
|`--check`| Check formatting without writing files. Exits with code 1 when files are different. |
38
-
|`--list-different`| Print only unformatted paths. Exits with code 1 when files are different. |
39
-
|`--parallel-workers <count>`| Set the maximum number of formatting workers. |
40
-
|`--stdin-filepath <path>`| Format stdin as if it were saved at `<path>` and print the result to stdout. |
41
-
|`-h, --help`| Display usage and option information. |
34
+
### `--check`
42
35
43
-
> `--write`, `--check`, and `--list-different` are mutually exclusive.
36
+
Check whether files are formatted without changing them. The output lists files with formatting issues and includes a human-friendly summary, making this option useful in CI:
44
37
45
-
> `--stdin-filepath` cannot be combined with `--write`, `--check`, `--list-different`, or file arguments.
38
+
```bash
39
+
rs fmt . --check
40
+
```
41
+
42
+
`--check` cannot be combined with `--write` or `--list-different`.
|`1`| One or more matched files have formatting issues. |
50
+
|`2`|`rs fmt` could not run or encountered a formatting error. |
51
+
52
+
### `-h, --help`
53
+
54
+
Display usage and option information without formatting files:
55
+
56
+
```bash
57
+
rs fmt --help
58
+
```
59
+
60
+
### `--list-different`
61
+
62
+
Print the paths of unformatted files without the summary produced by `--check`. This is useful when another command needs to consume the output:
63
+
64
+
```bash
65
+
rs fmt . --list-different
66
+
```
67
+
68
+
The option uses the same exit codes as `--check` and cannot be combined with `--write` or `--check`.
69
+
70
+
### `--parallel-workers <count>`
71
+
72
+
Set the maximum number of formatting workers to a positive integer:
73
+
74
+
```bash
75
+
rs fmt . --parallel-workers 4
76
+
```
77
+
78
+
When this option is omitted, `rs fmt` automatically chooses up to eight workers based on the available CPU parallelism and the number of matched files. Set a lower value to limit CPU or memory usage in constrained environments.
79
+
80
+
### `--stdin-filepath <path>`
81
+
82
+
Format content received from stdin as if it were saved at `<path>`. The path determines the parser and matching configuration overrides, but it does not need to exist on disk. The formatted content is written to stdout:
`--stdin-filepath` cannot be combined with file arguments or with `--write`, `--check`, or `--list-different`. See [Formatting stdin](../formatting#formatting-stdin) for details.
89
+
90
+
### `--write`
91
+
92
+
Write formatted files in place. This is the default mode, so specifying `--write` is optional:
93
+
94
+
```bash
95
+
rs fmt src --write
96
+
```
97
+
98
+
`--write` cannot be combined with `--check` or `--list-different`.
0 commit comments