From 7b530f5e52b12bb9beb241909bdc65838dc5a0b7 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 9 Apr 2017 19:50:22 +0200 Subject: combine files --- progress.go | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 progress.go (limited to 'progress.go') diff --git a/progress.go b/progress.go deleted file mode 100644 index 3f5df90..0000000 --- a/progress.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "context" - "fmt" - "strings" - "time" -) - -/* -__________..........__________..........__________..........__________.......... -Directory does not contain SHA256.sig. Continue without verification? [no] yes -Installing xshare58.tgz 100% |********************......| 4358 KB 00:12 ETA -Work 100% |**********************....| 25m0s ETA -*/ - -func progress(current, max time.Duration) string { - if current > max { - current = max - } - width := time.Duration(40) - n := width * current / max - done := strings.Repeat("*", int(n)) - left := strings.Repeat(".", int(width-n)) - return fmt.Sprintf("%3d%% |%v%v| %6s/%-6s", - 100*current/max, done, left, - current-current%time.Second, max-max%time.Second) -} - -func count(ctx context.Context, s string, d time.Duration) { - ctx, _ = context.WithTimeout(ctx, d) - start := time.Now() - defer fmt.Print("\n") - ticker := time.NewTicker(time.Second) - defer ticker.Stop() - for t := range ticker.C { - fmt.Printf("\r%-16s %v", s, progress(t.Sub(start), d)) - select { - case <-ctx.Done(): - return - default: - } - } -} -- cgit v1.2.3