X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=README.md;h=61e01dcb9fde267598da8b47a0db3bd11260a4b5;hb=95b6aa0dc8ee4ad5936bb185f5e6179a0c70bd16;hp=54a8bfc4c2ffd7f76598569a0de91695e8ab3a98;hpb=1ef94acec11b6f33795455ca47f43f8e62652259;p=rust.git diff --git a/README.md b/README.md index 54a8bfc4c2f..61e01dcb9fd 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,26 @@ A tool for formatting Rust code according to style guidelines. ## How to use +You'll need a pretty up to date version of the **nightly** version of Rust. +You will need a default.toml file in the current working directory when you run +the rustfmt command. You can look at this repo for an example default.toml file. + `cargo build` to build. `cargo test` to run all tests. -`cargo run filename` to run on a file, if the file includes out of line modules, +`cargo run -- filename` to run on a file, if the file includes out of line modules, then we reformat those too. So to run on a whole module or crate, you just need -to run on the top file. You'll probably want to set the `WriteMode` in the call -to `run` in `main()`. Eventually you should be able to set the mode from the -command line or from a config file or something. +to run on the top file. + +You'll probably want to specify the write mode. Currently, there are the replace, +overwrite and display mode. The replace mode is the default and overwrites the +original files after renaming them. In overwrite mode, rustfmt does not backup +the source files. To print the output to stdout, use the display mode. The write +mode can be set by passing the `--write-mode` flag on the command line. -You'll need a pretty up to date version of the nightly version of Rust. +`cargo run -- filename --write-mode=display` prints the output of rustfmt to the +screen, for example. ## Use cases @@ -200,8 +209,7 @@ It would be really useful to have people use rustfmt on their projects and file issues where it does something you don't expect. A really useful thing to do that on a crate from the Rust repo. If it does -something unexpected, file an issue; if not, make a PR to the Rust repo with the -reformatted code. I hope to get the whole repo consistently rustfmt'ed and to +something unexpected, file an issue; if not, make a PR to the Rust repo with the reformatted code. I hope to get the whole repo consistently rustfmt'ed and to replace `make tidy` with rustfmt as a medium-term goal. ### Create test cases