* Add multiple configuration file names feature
* Add '.rustfmt.toml' in README file
* Clean up configuration file code
* Make config file names constant
* Use only one blank line
This changes rustfmt to return exit code 4
when run with write mode diff and differences between
the formatted code and the original code are found.
Useful for CI to make sure your contributors actually ran rustfmt.
This will help in debugging issues as rustfmt gets more users.
If the working tree is clean, output looks like
$ target/debug/rustfmt -V
0.5.0 (9f5ed3b)
If the working tree is dirty, output looks like
$ target/debug/rustfmt -V
0.5.0 (9f5ed3b worktree dirty)
If git is unavailable, output looks like
$ target/debug/rustfmt -V
0.5.0 (git commit unavailable)
To avoid rebuilds on changing tests, the build script will only rerun if
files under src/ are changed. This means the actual git status may show
changed files and this would not show up in the version. This should not
be an issue as files not in src/ should not affect the build output.
`update_config()` was parsing the `write-mode` option once for each file
argument. This commit parses them once up front into a `CliOptions`
struct, which is then applied to the config before calling `run()`.
This commit tidies up handling of `write_mode` by setting it in the
config at the start, and removing the `write_mode` parameter threaded
throughout the formatting process.
Adds a config-path option for rustfmt. If this argument is provided,
it recursively searches the config-path for a rustfmt.toml file.
If file is not found, reverts to searching the file input path for the
config file or uses default options.
Previously errors were being silently ignored. Eg, if `rustfmt` did not
have permission to read a `rustfmt.toml` file, the default configuration
was used without informing the user.
`lookup_project_file` could erroneously find a *directory* named
`rustmfmt.toml` if there was one in its lookup path, and so ignore any
configuration file it should have found further up. The error handling
resulted in this silently using the default configuration.
Also from @marcusklaas:
Refactor code output functions
Specifically, `write_all_files` no longer returns a HashMap. It would sometimes
contain items, and sometimes be empty. When "fixed" newlines are required, this
must now be done with a separate call. The tests use this strategy and should now pass!
Since replace is the default rustfmt write mode, there's no need to
call rustfmt with `--write-mode=replace`. As a bonus, it is now also
possible to override the write-mode.
Add a new utility, which formats all readable .rs files in the src
directory of the crate using rustfmt. Both binaries can be installed
using cargo install rustfmt. cargo-fmt can be used as a Cargo
subcommand - cargo fmt.
Usage messages traditionally use this as it contains the path that the
user provided to run the executable (e.g. `rustfmt` instead of
`/usr/local/bin/rustfmt`).