Beispiel #1
0
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()))
}