Change the writemode to overwrite
This commit is contained in:
parent
cf195fb326
commit
6984c05e69
6 changed files with 13 additions and 22 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -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)",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
|
||||
name = "rustfmt-nightly"
|
||||
version = "0.1.9"
|
||||
version = "0.2.0"
|
||||
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
|
||||
description = "Tool to find and fix Rust formatting issues"
|
||||
repository = "https://github.com/rust-lang-nursery/rustfmt"
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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.";
|
||||
|
|
Loading…
Add table
Reference in a new issue