diff --git a/src/progress.rs b/src/progress.rs index d92c29c..7c3a7b9 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -42,7 +42,6 @@ pub trait Progress { /// used when a task fails; we want the final output to show that failed /// task's output even if we do more work after it fails. fn log(&mut self, msg: &str); - fn log_ignore_quiet(&mut self, msg: &str); } /// Currently running build task, as tracked for progress updates. @@ -65,16 +64,14 @@ pub struct DumbConsoleProgress { /// The id of the last command printed, used to avoid printing it twice /// when we have two updates from the same command in a row. last_started: Option, - quiet: bool, callback: Option>, } impl DumbConsoleProgress { - pub fn new(verbose: bool, quiet: bool, callback: Option>) -> Self { + pub fn new(verbose: bool, callback: Option>) -> Self { Self { verbose, last_started: None, - quiet, callback, } } @@ -108,9 +105,9 @@ impl Progress for DumbConsoleProgress { } } Termination::Interrupted => { - self.log_ignore_quiet(&format!("interrupted: {}", build_message(build))) + self.log(&format!("interrupted: {}", build_message(build))) } - Termination::Failure => self.log_ignore_quiet(&format!( + Termination::Failure => self.log(&format!( "{} {}", "failed:".red().bold(), build_message(build) @@ -127,22 +124,11 @@ impl Progress for DumbConsoleProgress { } fn log(&mut self, msg: &str) { - if !self.quiet { - if let Some(ref callback) = self.callback { - callback(msg); - } else { - println!("{}", msg); - } - } - } - - fn log_ignore_quiet(&mut self, msg: &str) { - if let Some(ref callback) = self.callback { - callback(msg); - } else { + if self.callback.is_none() { println!("{}", msg); } } + } /// Progress implementation for "fancy" console, with progress bar etc. @@ -159,7 +145,7 @@ pub struct FancyConsoleProgress { const UPDATE_DELAY: Duration = std::time::Duration::from_millis(50); impl FancyConsoleProgress { - pub fn new(verbose: bool, quiet: bool, callback: Option>) -> Self { + pub fn new(verbose: bool, callback: Option>) -> Self { let dirty_cond = Arc::new(Condvar::new()); let state = Arc::new(Mutex::new(FancyState { done: false, @@ -168,7 +154,6 @@ impl FancyConsoleProgress { counts: StateCounts::default(), tasks: VecDeque::new(), verbose, - quiet, callback, })); @@ -224,15 +209,9 @@ impl Progress for FancyConsoleProgress { } fn log(&mut self, msg: &str) { - if self.state.lock().unwrap().quiet { - return; - } self.state.lock().unwrap().log(msg); } - fn log_ignore_quiet(&mut self, msg: &str) { - self.state.lock().unwrap().log(msg); - } } impl Drop for FancyConsoleProgress { @@ -253,7 +232,6 @@ struct FancyState { tasks: VecDeque, /// Whether to print command lines of started programs. verbose: bool, - quiet: bool, callback: Option>, } @@ -300,9 +278,9 @@ impl FancyState { } } Termination::Interrupted => { - self.log_ignore_quiet(&format!("interrupted: {}", build_message(build))) + self.log(&format!("interrupted: {}", build_message(build))) } - Termination::Failure => self.log_ignore_quiet(&format!( + Termination::Failure => self.log(&format!( "{} {}", "failed:".red().bold(), build_message(build) @@ -320,23 +298,8 @@ impl FancyState { } fn log(&mut self, msg: &str) { - if self.quiet { - return; - } - self.clear_progress(); - if let Some(ref callback) = self.callback { - callback(msg); - } else { - println!("{}", msg); - } - self.dirty(); - } - - fn log_ignore_quiet(&mut self, msg: &str) { self.clear_progress(); - if let Some(ref c) = self.callback { - c(msg); - } else { + if self.callback.is_none() { println!("{}", msg); } self.dirty(); @@ -355,9 +318,6 @@ impl FancyState { } fn print_progress(&mut self) { - if self.quiet { - return; - } self.clear_progress(); let failed = self.counts.get(BuildState::Failed); let mut progress_line = format!( diff --git a/src/run.rs b/src/run.rs index d51d3d6..8730327 100644 --- a/src/run.rs +++ b/src/run.rs @@ -14,10 +14,10 @@ fn build( ) -> anyhow::Result> { let (mut dumb_console, mut fancy_console); let progress: &mut dyn Progress = if terminal::use_fancy() { - fancy_console = FancyConsoleProgress::new(verbose, false, None); + fancy_console = FancyConsoleProgress::new(verbose, None); &mut fancy_console } else { - dumb_console = DumbConsoleProgress::new(verbose, false, None); + dumb_console = DumbConsoleProgress::new(verbose, None); &mut dumb_console };