diff --git a/examples/customization/pacman.go b/examples/customization/pacman.go new file mode 100644 index 0000000..22f263a --- /dev/null +++ b/examples/customization/pacman.go @@ -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") +}