package ui import ( "fmt" "os" "github.com/fatih/color" "github.com/gosuri/uitable" ) func Error(s string) { color.Red(s) } func ErrorWithExit(s string) { color.Red(s) os.Exit(1) } type KV struct { K string V string } func KVTable(kvs []KV) { table := uitable.New() table.MaxColWidth = 100 table.Wrap = true // wrap columns table.AddRow("") for _, i := range kvs { if i.V == "" { table.AddRow(i.K, "-") } else { table.AddRow(i.K, i.V) } } fmt.Println(table) }