Skip to content

Commit

Permalink
Added basic pacman customization
Browse files Browse the repository at this point in the history
  • Loading branch information
wystans committed Nov 30, 2021
1 parent 7486f6b commit 828f3bf
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/customization/pacman.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"fmt"
"time"

"github.com/k0kubun/go-ansi"
"github.com/schollz/progressbar/v3"
)

func main() {
doneCh := make(chan struct{})

bar := progressbar.NewOptions(1000,
progressbar.OptionSetWriter(ansi.NewAnsiStdout()),
progressbar.OptionEnableColorCodes(true),
progressbar.OptionSetWidth(50),
progressbar.OptionSetTheme(progressbar.Theme{
Saucer: " ",
SaucerHead: "[yellow]<[reset]",
SaucerPadding: "[white]•",
BarStart: "[blue]|[reset]",
BarEnd: "[blue]|[reset]",
}),
progressbar.OptionOnCompletion(func() {
doneCh <- struct{}{}
}),
)

go func() {
for i := 0; i < 1000; i++ {
bar.Add(1)
time.Sleep(5 * time.Millisecond)
}
}()

// got notified that progress bar is complete.
<-doneCh
fmt.Println("\n ======= progress bar completed ==========\n")
}

0 comments on commit 828f3bf

Please sign in to comment.