aboutsummaryrefslogtreecommitdiff
path: root/internal/progress/new.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-08 14:15:38 +0800
committerGravatar Runxi Yu2026-03-08 14:15:38 +0800
commitc75a034d25ca87f3d209a8e82c743b8a7e96573b (patch)
treed8cd5befb9d812ab622dcce094c9d30797d6d861 /internal/progress/new.go
parent*: BestEffortFprintf as linter wants (diff)
signatureNo signature
internal/progress: Add progress meter
Diffstat (limited to 'internal/progress/new.go')
-rw-r--r--internal/progress/new.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/progress/new.go b/internal/progress/new.go
new file mode 100644
index 00000000..a86a0660
--- /dev/null
+++ b/internal/progress/new.go
@@ -0,0 +1,22 @@
+package progress
+
+import "time"
+
+// New creates one progress meter.
+func New(opts Options) *Meter {
+ now := time.Now()
+
+ return &Meter{
+ writer: opts.Writer,
+ flush: opts.Flush,
+ title: opts.Title,
+ total: opts.Total,
+ delay: max(opts.Delay, time.Duration(0)),
+ sparse: opts.Sparse,
+ throughput: opts.Throughput,
+ startedAt: now,
+ nextUpdateAt: now.Add(updateInterval),
+ nextThroughput: now.Add(throughputInterval),
+ lastPercent: -1,
+ }
+}