Ejemplo n.º 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()))
}
Ejemplo n.º 2
0
func printTable1(c *clif.Command, out clif.Output) {
	headers := []string{"H1", "H2", "H3"}
	var table *clif.Table
	if c.Option("open").Bool() {
		table = out.Table(headers, clif.OpenTableStyle)
	} else {
		table = out.Table(headers)
	}
	table.AddRows([][]string{
		[]string{"foo", "bar", "baz"},
		[]string{"yadda", "yadda", "yadda"},
		[]string{"Some crazy multi line content + Some crazy multi line content + Some crazy multi line content", "yadda", "yadda"},
		[]string{"yadda", "Some crazy multi line content + Some crazy multi line content + Some crazy multi line content", "yadda"},
		[]string{"yadda", "yadda", "Some crazy multi line content + Some crazy multi line content + Some crazy multi line content"},
		[]string{"Some <info>crazy multi line content + Some crazy multi line content + Some crazy<reset> multi line content", "yadda", "yadda"},
		[]string{"yadda", "Some <info>crazy multi line content + Some crazy multi line content + Some crazy<reset> multi line content", "yadda"},
		[]string{"yadda", "yadda", "Some <info>crazy multi line content + Some crazy multi line content + Some crazy<reset> multi line content"},
	})
	fmt.Println(table.Render(c.Option("render-width").Int()))
}