Skip to content

Commit

Permalink
cli: erase progress feedback on completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Oct 24, 2022
1 parent e773709 commit 78f2de2
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub struct Progress<'a> {
next_print: Instant,
rate: RateEstimate,
buffer: String,
printed: bool,
}

impl<'a> Progress<'a> {
Expand All @@ -20,7 +19,6 @@ impl<'a> Progress<'a> {
next_print: now + INITIAL_DELAY,
rate: RateEstimate::new(),
buffer: String::new(),
printed: false,
}
}

Expand All @@ -34,7 +32,6 @@ impl<'a> Progress<'a> {
if now < self.next_print {
return;
}
self.printed = true;
self.next_print = now.min(self.next_print + Duration::from_secs(1) / UPDATE_HZ);

self.buffer.clear();
Expand Down Expand Up @@ -63,9 +60,7 @@ impl<'a> Progress<'a> {

impl Drop for Progress<'_> {
fn drop(&mut self) {
if self.printed {
let _ = writeln!(self.ui);
}
_ = write!(self.ui, "\r{}", Clear(ClearType::CurrentLine));
}
}

Expand Down

0 comments on commit 78f2de2

Please sign in to comment.