diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/progress-bar/progress-bar.go | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/cmd/progress-bar/progress-bar.go b/cmd/progress-bar/progress-bar.go deleted file mode 100644 index 19050c8..0000000 --- a/cmd/progress-bar/progress-bar.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "bytes" - "errors" - "flag" - "fmt" - "os" - "os/exec" - "strconv" - "time" - - "gitlab.com/rhogenson/progress-bar" -) - -var n = flag.Duration("n", 2*time.Minute, "polling interval") - -func run() error { - args := flag.Args() - if len(args) < 2 { - return errors.New("usage error") - } - maxStr := args[0] - maxVal, err := strconv.Atoi(maxStr) - if err != nil { - return fmt.Errorf("max: %s", err) - } - cmd := args[1:] - bar := progress.New(maxVal) - for i := 0; ; i++ { - outputBytes, err := exec.Command(cmd[0], cmd[1:]...).Output() - if err != nil { - fmt.Println(err) - continue - } - output, err := strconv.Atoi(string(bytes.TrimSuffix(outputBytes, []byte("\n")))) - if err != nil { - fmt.Println(err) - continue - } - bar.Set(output) - bar.Print() - time.Sleep(*n) - } -} - -func main() { - flag.Parse() - if err := run(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} |
