Add duration

This commit is contained in:
2025-03-24 16:54:09 +04:00
parent a170588574
commit 59f40ad825
10 changed files with 232 additions and 70 deletions

View File

@ -17,7 +17,7 @@ import (
func streamProgress(
ctx context.Context,
wg *sync.WaitGroup,
total int64,
total uint,
message string,
increase <-chan int64,
) {
@ -27,21 +27,26 @@ func streamProgress(
pw.SetStyle(progress.StyleBlocks)
pw.SetTrackerLength(40)
pw.SetUpdateFrequency(time.Millisecond * 250)
if total == 0 {
pw.Style().Visibility.Percentage = false
}
go pw.Render()
dodosTracker := progress.Tracker{
Message: message,
Total: total,
Total: int64(total),
}
pw.AppendTracker(&dodosTracker)
for {
select {
case <-ctx.Done():
if ctx.Err() != context.Canceled {
if err := ctx.Err(); err == context.Canceled || err == context.DeadlineExceeded {
dodosTracker.MarkAsDone()
} else {
dodosTracker.MarkAsErrored()
}
time.Sleep(time.Millisecond * 300)
fmt.Printf("\r")
time.Sleep(time.Millisecond * 500)
pw.Stop()
return
case value := <-increase: