diff --git a/axoupdater/src/lib.rs b/axoupdater/src/lib.rs index 6068f1c..0f04d9c 100644 --- a/axoupdater/src/lib.rs +++ b/axoupdater/src/lib.rs @@ -5,6 +5,7 @@ use std::{ env::{self, args, current_dir}, path::PathBuf, + process::Stdio, }; #[cfg(unix)] @@ -45,6 +46,10 @@ pub struct AxoUpdater { latest_release: Option, /// The current version number current_version: Option, + /// Whether to display the underlying installer's stdout + print_installer_stdout: bool, + /// Whether to display the underlying installer's stderr + print_installer_stderr: bool, } impl Default for AxoUpdater { @@ -63,6 +68,8 @@ impl AxoUpdater { source: None, latest_release: None, current_version: None, + print_installer_stdout: true, + print_installer_stderr: true, } } @@ -73,6 +80,8 @@ impl AxoUpdater { source: None, latest_release: None, current_version: None, + print_installer_stdout: true, + print_installer_stderr: true, } } @@ -94,6 +103,8 @@ impl AxoUpdater { source: None, latest_release: None, current_version: None, + print_installer_stdout: true, + print_installer_stderr: true, }) } @@ -122,6 +133,50 @@ impl AxoUpdater { Ok(self) } + /// Enables printing the underlying installer's stdout. + pub fn enable_installer_stdout(&mut self) -> &mut AxoUpdater { + self.print_installer_stdout = true; + + self + } + + /// Disables printing the underlying installer's stdout. + pub fn disable_installer_stdout(&mut self) -> &mut AxoUpdater { + self.print_installer_stdout = false; + + self + } + + /// Enables printing the underlying installer's stderr. + pub fn enable_installer_stderr(&mut self) -> &mut AxoUpdater { + self.print_installer_stderr = true; + + self + } + + /// Disables printing the underlying installer's stderr. + pub fn disable_installer_stderr(&mut self) -> &mut AxoUpdater { + self.print_installer_stderr = false; + + self + } + + /// Enables all output for the underlying installer. + pub fn enable_installer_output(&mut self) -> &mut AxoUpdater { + self.print_installer_stdout = true; + self.print_installer_stderr = true; + + self + } + + /// Disables all output for the underlying installer. + pub fn disable_installer_output(&mut self) -> &mut AxoUpdater { + self.print_installer_stdout = false; + self.print_installer_stderr = false; + + self + } + /// Determines if an update is needed by querying the newest version from /// the location specified in `source`. /// This includes a blocking network call, so it may be slow. @@ -226,6 +281,12 @@ impl AxoUpdater { if cfg!(windows) { command.arg(&installer_path); } + if !self.print_installer_stdout { + command.stdout(Stdio::null()); + } + if !self.print_installer_stderr { + command.stderr(Stdio::null()); + } command.run()?; let result = UpdateResult {