func printProgress(c *clif.Command, count int, out clif.Output) { out.Printf("<headline>Progressing</headline>\n") var wg sync.WaitGroup pb := out.ProgressBars() if width := c.Option("width").Int(); width > 0 { pb.Width(width) } interval := c.Option("interval").Int() style := clif.ProgressBarStyleUtf8 if c.Option("ascii-style").Bool() { style = clif.ProgressBarStyleAscii } style.Count = clif.PROGRESS_BAR_ADDON_APPEND style.Estimate = clif.PROGRESS_BAR_ADDON_PREPEND pb.Style(style) pb.Start() for i := 0; i < count; i++ { name := fmt.Sprintf("bar%d", i) bar, _ := pb.Init(name, 200) wg.Add(1) go func(b clif.ProgressBar, t int) { defer wg.Done() for i := 0; i < 200; i++ { b.Increment() //<-time.After(time.Millisecond * time.Duration((t+1)*3)) <-time.After(time.Millisecond * time.Duration(interval*(t+1))) } }(bar, i) } wg.Wait() pb.Finish() }
func printTable2(c *clif.Command, out clif.Output) { out.Printf("<headline>Generating table</headline>\n\n") headers := []string{"Name", "Age", "Force"} var table *clif.Table if c.Option("open").Bool() { table = out.Table(headers, clif.OpenTableStyleLight) } else { table = out.Table(headers) } users := [][]string{ { "<important>Yoda<reset>", "Very, very old", "Like the uber guy", }, { "<important>Luke Skywalker<reset>", "Not that old", "A bit, but not that much", }, { "<important>Anakin Skywalker<reset>", "Old dude", "He is Lukes father! Was kind of stronger in 1-3, but still failed to" + " kill Jar Jar Binks. Not even tried, though. What's with that?", }, } for _, user := range users { table.AddRow(user) } fmt.Println(table.Render(c.Option("render-width").Int())) }