@@ -42,7 +42,8 @@ pub trait Progress {
4242 /// used when a task fails; we want the final output to show that failed
4343 /// task's output even if we do more work after it fails.
4444 fn log ( & mut self , msg : & str ) ;
45- fn log_ignore_quiet ( & mut self , msg : & str ) ;
45+
46+ fn log_when_failed ( & mut self , msg : & str ) ;
4647}
4748
4849/// Currently running build task, as tracked for progress updates.
@@ -65,16 +66,14 @@ pub struct DumbConsoleProgress {
6566 /// The id of the last command printed, used to avoid printing it twice
6667 /// when we have two updates from the same command in a row.
6768 last_started : Option < BuildId > ,
68- quiet : bool ,
6969 callback : Option < Box < dyn Fn ( & str ) + Send > > ,
7070}
7171
7272impl DumbConsoleProgress {
73- pub fn new ( verbose : bool , quiet : bool , callback : Option < Box < dyn Fn ( & str ) + Send > > ) -> Self {
73+ pub fn new ( verbose : bool , callback : Option < Box < dyn Fn ( & str ) + Send > > ) -> Self {
7474 Self {
7575 verbose,
7676 last_started : None ,
77- quiet,
7877 callback,
7978 }
8079 }
@@ -108,13 +107,11 @@ impl Progress for DumbConsoleProgress {
108107 }
109108 }
110109 Termination :: Interrupted => {
111- self . log_ignore_quiet ( & format ! ( "interrupted: {}" , build_message( build) ) )
110+ self . log_when_failed ( & format ! ( "interrupted: {}" , build_message( build) ) )
111+ }
112+ Termination :: Failure => {
113+ self . log_when_failed ( & format ! ( "failed: {}" , build_message( build) ) )
112114 }
113- Termination :: Failure => self . log_ignore_quiet ( & format ! (
114- "{} {}" ,
115- "failed:" . red( ) . bold( ) ,
116- build_message( build)
117- ) ) ,
118115 } ;
119116 if !result. output . is_empty ( ) {
120117 if let Some ( ref callback) = self . callback {
@@ -127,21 +124,13 @@ impl Progress for DumbConsoleProgress {
127124 }
128125
129126 fn log ( & mut self , msg : & str ) {
130- if !self . quiet {
131- if let Some ( ref callback) = self . callback {
132- callback ( msg) ;
133- } else {
134- println ! ( "{}" , msg) ;
135- }
127+ if self . callback . is_none ( ) {
128+ println ! ( "{}" , msg) ;
136129 }
137130 }
138131
139- fn log_ignore_quiet ( & mut self , msg : & str ) {
140- if let Some ( ref callback) = self . callback {
141- callback ( msg) ;
142- } else {
143- println ! ( "{}" , msg) ;
144- }
132+ fn log_when_failed ( & mut self , msg : & str ) {
133+ println ! ( "{}" , msg) ;
145134 }
146135}
147136
@@ -159,7 +148,7 @@ pub struct FancyConsoleProgress {
159148const UPDATE_DELAY : Duration = std:: time:: Duration :: from_millis ( 50 ) ;
160149
161150impl FancyConsoleProgress {
162- pub fn new ( verbose : bool , quiet : bool , callback : Option < Box < dyn Fn ( & str ) + Send > > ) -> Self {
151+ pub fn new ( verbose : bool , callback : Option < Box < dyn Fn ( & str ) + Send > > ) -> Self {
163152 let dirty_cond = Arc :: new ( Condvar :: new ( ) ) ;
164153 let state = Arc :: new ( Mutex :: new ( FancyState {
165154 done : false ,
@@ -168,7 +157,6 @@ impl FancyConsoleProgress {
168157 counts : StateCounts :: default ( ) ,
169158 tasks : VecDeque :: new ( ) ,
170159 verbose,
171- quiet,
172160 callback,
173161 } ) ) ;
174162
@@ -224,14 +212,11 @@ impl Progress for FancyConsoleProgress {
224212 }
225213
226214 fn log ( & mut self , msg : & str ) {
227- if self . state . lock ( ) . unwrap ( ) . quiet {
228- return ;
229- }
230215 self . state . lock ( ) . unwrap ( ) . log ( msg) ;
231216 }
232217
233- fn log_ignore_quiet ( & mut self , msg : & str ) {
234- self . state . lock ( ) . unwrap ( ) . log ( msg) ;
218+ fn log_when_failed ( & mut self , msg : & str ) {
219+ self . state . lock ( ) . unwrap ( ) . log_when_failed ( msg) ;
235220 }
236221}
237222
@@ -253,7 +238,6 @@ struct FancyState {
253238 tasks : VecDeque < Task > ,
254239 /// Whether to print command lines of started programs.
255240 verbose : bool ,
256- quiet : bool ,
257241 callback : Option < Box < dyn Fn ( & str ) + Send > > ,
258242}
259243
@@ -299,10 +283,12 @@ impl FancyState {
299283 self . log ( build_message ( build) )
300284 }
301285 }
302- Termination :: Interrupted => {
303- self . log_ignore_quiet ( & format ! ( "interrupted: {}" , build_message( build) ) )
304- }
305- Termination :: Failure => self . log_ignore_quiet ( & format ! (
286+ Termination :: Interrupted => self . log_when_failed ( & format ! (
287+ "{} {}" ,
288+ "interrupted:" . red( ) ,
289+ build_message( build)
290+ ) ) ,
291+ Termination :: Failure => self . log_when_failed ( & format ! (
306292 "{} {}" ,
307293 "failed:" . red( ) . bold( ) ,
308294 build_message( build)
@@ -320,25 +306,16 @@ impl FancyState {
320306 }
321307
322308 fn log ( & mut self , msg : & str ) {
323- if self . quiet {
324- return ;
325- }
326309 self . clear_progress ( ) ;
327- if let Some ( ref callback) = self . callback {
328- callback ( msg) ;
329- } else {
310+ if self . callback . is_none ( ) {
330311 println ! ( "{}" , msg) ;
331312 }
332313 self . dirty ( ) ;
333314 }
334315
335- fn log_ignore_quiet ( & mut self , msg : & str ) {
316+ fn log_when_failed ( & mut self , msg : & str ) {
336317 self . clear_progress ( ) ;
337- if let Some ( ref c) = self . callback {
338- c ( msg) ;
339- } else {
340- println ! ( "{}" , msg) ;
341- }
318+ println ! ( "{}" , msg) ;
342319 self . dirty ( ) ;
343320 }
344321
@@ -352,13 +329,14 @@ impl FancyState {
352329 // If the user hit ctl-c, it may have printed something on the line.
353330 // So \r to go to first column first, then clear anything below.
354331 std:: io:: stdout ( ) . write_all ( b"\r \x1b [J" ) . unwrap ( ) ;
332+ let _ = std:: io:: stdout ( ) . flush ( ) ;
355333 }
356334
357335 fn print_progress ( & mut self ) {
358- if self . quiet {
336+ self . clear_progress ( ) ;
337+ if self . done {
359338 return ;
360339 }
361- self . clear_progress ( ) ;
362340 let failed = self . counts . get ( BuildState :: Failed ) ;
363341 let mut progress_line = format ! (
364342 "[{}] {}/{} done, " ,
0 commit comments