mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 01:05:39 +03:00
Add --backup flag
This commit is contained in:
@@ -91,6 +91,7 @@ fn make_opts() -> Options {
|
||||
let mut opts = Options::new();
|
||||
|
||||
// Sorted in alphabetical order.
|
||||
opts.optflag("", "backup", "Backup any modified files.");
|
||||
opts.optflag(
|
||||
"",
|
||||
"check",
|
||||
|
||||
@@ -368,7 +368,11 @@ pub fn from_matches(matches: &Matches) -> FmtResult<CliOptions> {
|
||||
return Err(format_err!("Invalid to set write-mode and `--check`"));
|
||||
}
|
||||
if let Ok(write_mode) = WriteMode::from_str(write_mode) {
|
||||
options.write_mode = Some(write_mode);
|
||||
if write_mode == WriteMode::Overwrite && matches.opt_present("backup") {
|
||||
options.write_mode = Some(WriteMode::Replace);
|
||||
} else {
|
||||
options.write_mode = Some(write_mode);
|
||||
}
|
||||
} else {
|
||||
return Err(format_err!(
|
||||
"Invalid write-mode: {}, expected one of {}",
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@
|
||||
|
||||
pub type FmtResult<T> = std::result::Result<T, failure::Error>;
|
||||
|
||||
pub const WRITE_MODE_LIST: &str = "[replace|overwrite|display|plain|diff|coverage|checkstyle]";
|
||||
pub const WRITE_MODE_LIST: &str = "[overwrite|display|plain|diff|coverage|checkstyle]";
|
||||
|
||||
#[macro_use]
|
||||
mod utils;
|
||||
|
||||
Reference in New Issue
Block a user