diff --git a/Cargo.lock b/Cargo.lock index 8dff7cbcff5..efad18d5abc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "rustfmt-nightly" -version = "0.1.9" +version = "0.2.0" dependencies = [ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index a82883b2d8b..5ac6bf54144 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustfmt-nightly" -version = "0.1.9" +version = "0.2.0" authors = ["Nicholas Cameron ", "The Rustfmt developers"] description = "Tool to find and fix Rust formatting issues" repository = "https://github.com/rust-lang-nursery/rustfmt" diff --git a/Configurations.md b/Configurations.md index f97214c1358..5c75030d480 100644 --- a/Configurations.md +++ b/Configurations.md @@ -2120,5 +2120,5 @@ See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comm What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage -- **Default value**: `"Replace"` +- **Default value**: `"Overwrite"` - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"` diff --git a/README.md b/README.md index 4b7210dd06e..f7efdfeb266 100644 --- a/README.md +++ b/README.md @@ -90,11 +90,12 @@ read data from stdin. Alternatively, you can use `cargo fmt` to format all binary and library targets of your crate. You'll probably want to specify the write mode. Currently, there are modes for -diff, replace, overwrite, display, coverage, and checkstyle. +`diff`, `replace`, `overwrite`, `display`, `coverage`, `checkstyle`, and `plain`. -* `replace` Is the default and overwrites the original files after creating backups of the files. -* `overwrite` Overwrites the original files _without_ creating backups. +* `overwrite` Is the default and overwrites the original files _without_ creating backups. +* `replace` Overwrites the original files after creating backups of the files. * `display` Will print the formatted files to stdout. +* `plain` Also writes to stdout, but with no metadata. * `diff` Will print a diff between the original files and formatted files to stdout. Will also exit with an error code if there are any differences. * `checkstyle` Will output the lines that need to be corrected as a checkstyle XML file, @@ -103,7 +104,7 @@ diff, replace, overwrite, display, coverage, and checkstyle. The write mode can be set by passing the `--write-mode` flag on the command line. For example `rustfmt --write-mode=display src/filename.rs` -`cargo fmt` uses `--write-mode=replace` by default. +`cargo fmt` uses `--write-mode=overwrite` by default. If you want to restrict reformatting to specific sets of lines, you can use the `--file-lines` option. Its argument is a JSON array of objects diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs index f0846b43ea8..2de572f616e 100644 --- a/src/bin/rustfmt.rs +++ b/src/bin/rustfmt.rs @@ -78,11 +78,6 @@ impl CliOptions { format!("Invalid write-mode: {}", write_mode), )); } - } else if !matches.opt_present("no-warn-write-mode") { - println!( - "Warning: the default write-mode for Rustfmt will soon change to overwrite \ - - this will not leave backups of changed files." - ); } if let Some(ref file_lines) = matches.opt_str("file-lines") { @@ -120,17 +115,11 @@ fn make_opts() -> Options { opts.optflag("h", "help", "show this message"); opts.optflag("V", "version", "show version information"); opts.optflag("v", "verbose", "print verbose output"); - // Suppress warning. Remove this option after the default write mode changed to overwrite. - opts.optflag( - "w", - "no-warn-write-mode", - "inhibit warning about write-mode change", - ); opts.optopt( "", "write-mode", - "mode to write in (not usable when piping from stdin)", - "[replace|overwrite|display|diff|coverage|checkstyle]", + "how to write output (not usable when piping from stdin)", + "[replace|overwrite|display|plain|diff|coverage|checkstyle]", ); opts.optflag("", "skip-children", "don't reformat child modules"); diff --git a/src/config.rs b/src/config.rs index 173f076bebb..7ffe141e6c1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -596,8 +596,9 @@ create_config! { spaces_within_square_brackets: bool, false, "Put spaces within non-empty square brackets"; spaces_within_parens: bool, false, "Put spaces within non-empty parentheses"; use_try_shorthand: bool, false, "Replace uses of the try! macro by the ? shorthand"; - write_mode: WriteMode, WriteMode::Replace, - "What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage"; + write_mode: WriteMode, WriteMode::Overwrite, + "What Write Mode to use when none is supplied: \ + Replace, Overwrite, Display, Plain, Diff, Coverage"; condense_wildcard_suffixes: bool, false, "Replace strings of _ wildcards by a single .. in \ tuple patterns"; combine_control_expr: bool, true, "Combine control expressions with funciton calls.";