From 433702f4218c81c1ef2565b5f765172cc2f90e96 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 20 Nov 2023 14:22:39 -0500 Subject: [PATCH] hide progress stats on completion --- progress/bar.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/progress/bar.go b/progress/bar.go index baa4c5d4e..97bc15cfb 100644 --- a/progress/bar.go +++ b/progress/bar.go @@ -118,17 +118,25 @@ func (b *Bar) percent() float64 { } func (b *Bar) Stats() Stats { - if time.Since(b.statted) < time.Second || b.currentValue >= b.maxValue { + if time.Since(b.statted) < time.Second { return b.stats } - if b.statted.IsZero() { + switch { + case b.statted.IsZero(): + case b.currentValue >= b.maxValue: + b.stats = Stats{ + value: b.maxValue, + rate: 0, + remaining: 0, + } + case b.statted.IsZero(): b.stats = Stats{ value: b.initialValue, rate: 0, remaining: 0, } - } else { + default: rate := b.currentValue - b.stats.value var remaining time.Duration if rate > 0 {