shithub: furgit

ref: ab174c473618dd3743881cf44e02c2db4d1ecd5f
dir: /internal/progress/meter.go/

View raw version
package progress

import (
	"time"

	"codeberg.org/lindenii/furgit/common/iowrap"
)

// Meter renders one in-place progress line.
type Meter struct {
	writer iowrap.WriteFlusher

	title      string
	total      uint64
	delay      time.Duration
	sparse     bool
	throughput bool

	startedAt      time.Time
	nextUpdateAt   time.Time
	nextThroughput time.Time

	lastDone     uint64
	lastBytes    uint64
	lastPercent  int
	lastCounterW int
	sawValue     bool

	throughputSuffix string
}