Skip to content

Commit

Permalink
Merge pull request #186 from taufik-rama/add_disable_total
Browse files Browse the repository at this point in the history
Add 'HideCountersTotal' to disable counters total output
  • Loading branch information
cheggaaa committed Jul 7, 2021
2 parents 13462a2 + cd08fff commit 1d2bb0a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type ProgressBar struct {
ShowPercent, ShowCounters bool
ShowSpeed, ShowTimeLeft, ShowBar bool
ShowFinalTime, ShowElapsedTime bool
HideCountersTotal bool
Output io.Writer
Callback Callback
NotPrint bool
Expand Down Expand Up @@ -304,10 +305,18 @@ func (pb *ProgressBar) write(total, current int64) {
if pb.ShowCounters {
current := Format(current).To(pb.Units).Width(pb.UnitsWidth)
if total > 0 {
totalS := Format(total).To(pb.Units).Width(pb.UnitsWidth)
countersBox = fmt.Sprintf(" %s / %s ", current, totalS)
if pb.HideCountersTotal {
countersBox = fmt.Sprintf(" %s ", current)
} else {
totalS := Format(total).To(pb.Units).Width(pb.UnitsWidth)
countersBox = fmt.Sprintf(" %s / %s ", current, totalS)
}
} else {
countersBox = fmt.Sprintf(" %s / ? ", current)
if pb.HideCountersTotal {
countersBox = fmt.Sprintf(" %s ", current)
} else {
countersBox = fmt.Sprintf(" %s / ? ", current)
}
}
}

Expand Down

0 comments on commit 1d2bb0a

Please sign in to comment.