diff --git a/src/cli/download_tracker.rs b/src/cli/download_tracker.rs index 1bd3b208b3..ec07ea5ea0 100644 --- a/src/cli/download_tracker.rs +++ b/src/cli/download_tracker.rs @@ -186,13 +186,13 @@ impl DownloadTracker { (remaining / speed) as u64 }); format!( - "{} / {} ({:3.0} %) {} in {} ETA: {}", + "{} / {} ({:3.0} %) {} in {}{}", total_h, content_len_h, percent, speed_h, elapsed_h.display(), - eta_h.display(), + Eta(eta_h), ) } None => format!( @@ -220,6 +220,17 @@ impl DownloadTracker { } } +struct Eta(Duration); + +impl fmt::Display for Eta { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self.0 { + Duration::ZERO => Ok(()), + _ => write!(f, "{}", self.0.display()), + } + } +} + trait DurationDisplay { fn display(self) -> Display; }