Documentation ¶
Overview ¶
nolint:errcheck
nolint:errcheck
Index ¶
- Constants
- Variables
- func MarshalJSON(v interface{}) string
- func MarshalRAW(v interface{}) string
- func MarshalYAML(v interface{}) string
- func PadWithSpace(source string, prefix, suffix int) string
- func TruncateWithLength(source string, length int) string
- type Format
- func (f Format) Contains(sub string) bool
- func (f Format) Header() (*template.Template, error)
- func (f Format) IsBuffered() bool
- func (f Format) IsJSON() bool
- func (f Format) IsRaw() bool
- func (f Format) IsTable() bool
- func (f Format) IsYAML() bool
- func (f Format) String() string
- func (f Format) Template() (*template.Template, error)
- type Formatter
- type Header
Constants ¶
View Source
const ( TableFormatKey = "table" RawFormatKey = "raw" PrettyFormatKey = "pretty" JSONFormatKey = "json" YAMLFormatKey = "yaml" DefaultQuietFormat = "{{.ID}}" )
Format keys used to specify certain kinds of output formats
Variables ¶
View Source
var BasicFunctions = template.FuncMap{ "raw": MarshalRAW, "json": MarshalJSON, "yaml": MarshalYAML, "split": strings.Split, "join": strings.Join, "title": strings.Title, "lower": strings.ToLower, "upper": strings.ToUpper, "pad": PadWithSpace, "truncate": TruncateWithLength, }
BasicFunctions are the set of initial functions provided to every template.
View Source
var HeaderFunctions = template.FuncMap{ "raw": func(v string) string { return v }, "json": func(v string) string { return v }, "yaml": func(v string) string { return v }, "split": func(v string, _ string) string { return v }, "join": func(v string, _ string) string { return v }, "title": func(v string) string { return v }, "lower": func(v string) string { return v }, "upper": func(v string) string { return v }, "truncate": func(v string, _ int) string { return v }, }
HeaderFunctions are used to created headers of a table. This is a replacement of basicFunctions for header generation because we want the header to remain intact. Some functions like `pad` are not overridden (to preserve alignment with the columns).
Functions ¶
func MarshalJSON ¶
func MarshalJSON(v interface{}) string
func MarshalRAW ¶
func MarshalRAW(v interface{}) string
func MarshalYAML ¶
func MarshalYAML(v interface{}) string
func PadWithSpace ¶
PadWithSpace adds whitespace to the input if the input is non-empty
func TruncateWithLength ¶
TruncateWithLength truncates the source string up to the length provided by the input
Types ¶
type Format ¶
type Format string
Format is the format string rendered using the Context
func (Format) IsBuffered ¶
Click to show internal directories.
Click to hide internal directories.