Documentation
¶
Overview ¶
Package printer renders a Printable as a table, JSON, YAML or a Go template.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrColumnsOfRecords = errors.New("columns are picked for a table: json and yaml show whole records")
ErrColumnsOfRecords is the error for columns picked from JSON or YAML, which show whole records.
Functions ¶
func IsStructured ¶
IsStructured reports whether the format s names is machine-readable -- JSON or YAML -- rather than something for a person to read.
Types ¶
type Options ¶
type Options struct {
// Format is table, json, yaml, or a Go template.
Format string
// Columns are those a table shows. Empty means the default ones. JSON
// and YAML show whole records, so they take none.
Columns []string
// AllColumns shows every column in a table, not just the default ones.
AllColumns bool
}
Options are how Print renders.
type Printable ¶
Printable is implemented by anything a command can print. Columns names the columns in display order; Rows returns one map per row, keyed by column, for people: a table and a template show them. Records returns the list of records the rows are made from, for programs: JSON and YAML show them, with their raw values, as their JSON tags name them.
A Printable with more columns than a table shows by default also has a method DefaultColumns() []string. Asked for no columns in particular, a table shows those; a template still has every column.