2015-09-15 23:44:38 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ryanuber/columnize"
|
|
|
|
)
|
|
|
|
|
|
|
|
// formatKV takes a set of strings and formats them into properly
|
|
|
|
// aligned k = v pairs using the columnize library.
|
|
|
|
func formatKV(in []string) string {
|
|
|
|
columnConf := columnize.DefaultConfig()
|
2015-09-27 21:04:53 +00:00
|
|
|
columnConf.Empty = "<none>"
|
2015-09-15 23:44:38 +00:00
|
|
|
columnConf.Glue = " = "
|
|
|
|
return columnize.Format(in, columnConf)
|
|
|
|
}
|
|
|
|
|
|
|
|
// formatList takes a set of strings and formats them into properly
|
|
|
|
// aligned output, replacing any blank fields with a placeholder
|
|
|
|
// for awk-ability.
|
|
|
|
func formatList(in []string) string {
|
|
|
|
columnConf := columnize.DefaultConfig()
|
|
|
|
columnConf.Empty = "<none>"
|
|
|
|
return columnize.Format(in, columnConf)
|
|
|
|
}
|
2016-01-27 18:42:10 +00:00
|
|
|
|
|
|
|
// Limits the length of the string.
|
|
|
|
func limit(s string, length int) string {
|
|
|
|
if len(s) < length {
|
|
|
|
return s[:len(s)]
|
|
|
|
}
|
|
|
|
|
|
|
|
return s[:length]
|
|
|
|
}
|