fmt
The rs fmt command formats files or checks whether they are formatted. For detailed usage, see Formatting.
Usage
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 for path resolution and ignore rules.
Examples:
rs format is an alias for rs fmt:
Options
--check
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:
--check cannot be combined with --write or --list-different.
The command uses the following exit codes:
-h, --help
Display usage and option information without formatting files:
--ignore-path <path>
Load additional Gitignore-compatible rules from <path>. Repeat the option to load multiple
ignore files:
Relative ignore paths are resolved from the current working directory. Rules in each file are
resolved from the directory containing that ignore file and extend the built-in ignore rules and
define.fmt.ignorePatterns. They apply to scanned paths, explicitly passed files, and
--stdin-filepath. An unreadable ignore file causes the command to exit with code 2.
--list-different
Print the paths of unformatted files without the summary produced by --check. This is useful when another command needs to consume the output:
The option uses the same exit codes as --check and cannot be combined with --write or --check.
--parallel-workers <count>
Set the maximum number of formatting workers to a positive integer:
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.
--stdin-filepath <path>
Format content received from stdin as if it were saved at <path>, for example when integrating with an editor. The path determines the parser and matching configuration overrides, but it does not need to exist on disk:
Formatted output is written to stdout and diagnostics to stderr. If the input path is ignored, rs fmt skips formatting and writes the input unchanged. If it cannot infer a parser from the path or parse the content, it reports an error and exits with code 2.
--stdin-filepathcannot be combined with file arguments or with--write,--check, or--list-different.
--write
Write formatted files in place. This is the default mode, so specifying --write is optional:
--write cannot be combined with --check or --list-different.