Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8a04ec6

Browse files
committed
fix not to emit version
1 parent 378b28b commit 8a04ec6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/cargo-fmt/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn execute() -> i32 {
7979
}
8080

8181
if matches.opt_present("version") {
82-
return handle_command_status(get_version(verbosity), &opts);
82+
return handle_command_status(get_version(), &opts);
8383
}
8484

8585
let strategy = CargoFmtStrategy::from_matches(&matches);
@@ -122,8 +122,19 @@ fn handle_command_status(status: Result<i32, io::Error>, opts: &getopts::Options
122122
}
123123
}
124124

125-
fn get_version(verbosity: Verbosity) -> Result<i32, io::Error> {
126-
run_rustfmt(&BTreeSet::new(), &[String::from("--version")], verbosity)
125+
fn get_version() -> Result<i32, io::Error> {
126+
let mut status = vec![];
127+
let mut command = Command::new("rustfmt")
128+
.stdout(std::process::Stdio::inherit())
129+
.args(&[String::from("--version")])
130+
.spawn()?;
131+
status.push(command.wait()?);
132+
133+
Ok(status
134+
.iter()
135+
.filter_map(|s| if s.success() { None } else { s.code() })
136+
.next()
137+
.unwrap_or(SUCCESS))
127138
}
128139

129140
fn format_crate(verbosity: Verbosity, strategy: &CargoFmtStrategy) -> Result<i32, io::Error> {

0 commit comments

Comments
 (0)