C. rustfmt Command-Line Interface¶
- --check¶
Check if the input is well-formatted.
Exits with status code 0 if input is well-formatted. Exits with status code 1 and prints a diff if formatting is not correct.
- --emit [files|stdout]¶
What kind of output to emit.
filesemits formatted output to files; this is the defaultstdoutemits the formatted output to stdout
- --backup¶
Backup any modified files.
Before a file is modified, rustfmt will create a copy with the same path, except with
.rsextension replaced by.bk. Note that existing.bkfiles are silently over-written.
- --config-path¶
Recursively searches the given path for the
rustfmt.tomlor.rustfmt.tomlconfig file. If not found, it reverts to the default behavior of searching the parent directories of the file to be formatted.
- --edition [2015|2018|2021]¶
Rust edition to use, which defaults to 2015 edition.
If using a different edition than the default, specify it here, because the formatting may be different.
- --color [always|never|auto]¶
Use colored output (if supported)
- --print-config [Path for the configuration file]¶
Dumps a default or minimal config to PATH. A minimal config is the subset of the current config file used for formatting the current program.
currentwrites to stdout current config as if formatting the file at PATH.
- --files-with-diff¶
Short option:
-l.Prints the names of mismatched files that were formatted. When used with
--check, this option instead prints the names of files that are not well-formatted.
- --config [key1=val1,key2=val2...]¶
Set options from command line. These settings take priority over
.rustfmt.toml.
- --verbose¶
Short option:
-v.Print verbose output.
- --quiet¶
Short option:
-q.Print less output.
- --version¶
Short option:
-V.Show version information.
- --help [=TOPIC]¶
Short option:
-h.Show this message or help about a specific topic:
configorfile-lines.