forked from gosuri/uilive
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
27 lines (22 loc) · 717 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
import (
"fmt"
"time"
"github.com/gosuri/uilive"
)
func main() {
writer := uilive.New()
// start listening for updates and render
writer.Start()
for _, f := range [][]string{{"Foo.zip", "Bar.iso"}, {"Baz.tar.gz", "Qux.img"}} {
for i := 0; i <= 50; i++ {
_, _ = fmt.Fprintf(writer, "Downloading %s.. (%d/%d) GB\n", f[0], i, 50)
_, _ = fmt.Fprintf(writer.Newline(), "Downloading %s.. (%d/%d) GB\n", f[1], i, 50)
time.Sleep(time.Millisecond * 25)
}
_, _ = fmt.Fprintf(writer.Bypass(), "Downloaded %s\n", f[0])
_, _ = fmt.Fprintf(writer.Bypass(), "Downloaded %s\n", f[1])
}
_, _ = fmt.Fprintln(writer, "Finished: Downloaded 150GB")
writer.Stop() // flush and stop rendering
}