diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-05 14:24:07 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-05 14:24:07 -0700 |
| commit | 049211d719574b9af8453b044d56625fa4af39af (patch) | |
| tree | b4b3c473afc0242b5f69a7e3ffbe65d99ec27bbd /cmd | |
| parent | Use float values between 0 and 1 (diff) | |
| download | progress-bar-049211d719574b9af8453b044d56625fa4af39af.tar.zst | |
Fix bugs
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/progress-bar/progress-bar.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/progress-bar/progress-bar.go b/cmd/progress-bar/progress-bar.go index 65079ef..25e6216 100644 --- a/cmd/progress-bar/progress-bar.go +++ b/cmd/progress-bar/progress-bar.go @@ -10,7 +10,7 @@ import ( "strconv" "time" - "gitlab.com/rhogenson/progress-bar/progress" + "gitlab.com/rhogenson/progress-bar" ) var n = flag.Duration("n", 2*time.Minute, "polling interval") @@ -21,12 +21,13 @@ func run() error { return errors.New("usage error") } maxStr := args[0] - maxVal, err := strconv.Atoi(maxStr) + maxInt, err := strconv.Atoi(maxStr) if err != nil { return fmt.Errorf("max: %s", err) } + maxFloat := float64(maxInt) cmd := args[1:] - bar := progress.New(maxVal) + bar := new(progress.Bar) for i := 0; ; i++ { outputBytes, err := exec.Command(cmd[0], cmd[1:]...).Output() if err != nil { @@ -38,7 +39,7 @@ func run() error { fmt.Println(err) continue } - bar.Set(output) + bar.Set(float64(output) / maxFloat) bar.Print() time.Sleep(*n) } |
