diff --git a/src/cargo.rs b/src/cargo.rs index 14e9585e6..2cccda2d9 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -88,5 +88,7 @@ pub fn root() -> Result> { /// Pass-through mode pub fn run(args: &[String], verbose: bool) -> Result { - Command::new("cargo").args(args).run_and_get_status(verbose) + Command::new("cargo") + .args(args) + .run_and_get_status(verbose, false) } diff --git a/src/docker.rs b/src/docker.rs index e6499d0bd..5ec492111 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -50,7 +50,7 @@ pub fn register(target: &Target, verbose: bool) -> Result<()> { .arg("--rm") .arg("ubuntu:16.04") .args(&["sh", "-c", cmd]) - .run(verbose) + .run(verbose, false) } #[allow(clippy::too_many_arguments)] // TODO: refactor @@ -282,7 +282,7 @@ RUN $CMD" docker .arg(image) .args(&["sh", "-c", &format!("PATH=$PATH:/rust/bin {:?}", cmd)]) - .run_and_get_status(verbose) + .run_and_get_status(verbose, false) } #[derive(Debug, PartialEq)] @@ -347,7 +347,7 @@ impl<'a> Dockerfile<'a> { } } - docker_build.run(verbose)?; + docker_build.run(verbose, true)?; let image_name = if let Some(image) = self.image_name() { image.to_owned() diff --git a/src/extensions.rs b/src/extensions.rs index 9d9a5dd18..ebba836ad 100644 --- a/src/extensions.rs +++ b/src/extensions.rs @@ -7,8 +7,8 @@ use crate::errors::*; pub trait CommandExt { fn print_verbose(&self, verbose: bool); fn status_result(&self, status: ExitStatus) -> Result<()>; - fn run(&mut self, verbose: bool) -> Result<()>; - fn run_and_get_status(&mut self, verbose: bool) -> Result; + fn run(&mut self, verbose: bool, silence_stdout: bool) -> Result<()>; + fn run_and_get_status(&mut self, verbose: bool, silence_stdout: bool) -> Result; fn run_and_get_stdout(&mut self, verbose: bool) -> Result; } @@ -32,14 +32,17 @@ impl CommandExt for Command { } /// Runs the command to completion - fn run(&mut self, verbose: bool) -> Result<()> { - let status = self.run_and_get_status(verbose)?; + fn run(&mut self, verbose: bool, silence_stdout: bool) -> Result<()> { + let status = self.run_and_get_status(verbose, silence_stdout)?; self.status_result(status) } /// Runs the command to completion - fn run_and_get_status(&mut self, verbose: bool) -> Result { + fn run_and_get_status(&mut self, verbose: bool, silence_stdout: bool) -> Result { self.print_verbose(verbose); + if silence_stdout && !verbose { + self.stdout(std::process::Stdio::null()); + } self.status() .wrap_err_with(|| format!("couldn't execute `{:?}`", self)) } diff --git a/src/rustup.rs b/src/rustup.rs index aecd5e14d..6c37f27ea 100644 --- a/src/rustup.rs +++ b/src/rustup.rs @@ -70,7 +70,7 @@ pub fn available_targets(toolchain: &str, verbose: bool) -> Result Result<()> { Command::new("rustup") .args(&["toolchain", "add", toolchain, "--profile", "minimal"]) - .run(verbose) + .run(verbose, false) .wrap_err_with(|| format!("couldn't install toolchain `{toolchain}`")) } @@ -79,14 +79,14 @@ pub fn install(target: &Target, toolchain: &str, verbose: bool) -> Result<()> { Command::new("rustup") .args(&["target", "add", target, "--toolchain", toolchain]) - .run(verbose) + .run(verbose, false) .wrap_err_with(|| format!("couldn't install `std` for {target}")) } pub fn install_component(component: &str, toolchain: &str, verbose: bool) -> Result<()> { Command::new("rustup") .args(&["component", "add", component, "--toolchain", toolchain]) - .run(verbose) + .run(verbose, false) .wrap_err_with(|| format!("couldn't install the `{component}` component")) }