Documentation
¶
Overview ¶
Package output turns a decoded JSON reply into something on screen.
The default is a table for people; -o json is for pipes. The relationship between them is stated in --output's help: tables may be restyled at any time, JSON will not.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadColumnSpec = errors.New("malformed column specification") ErrBadFieldPath = errors.New("malformed field path") )
var ( ErrUnknownFormat = errors.New("unknown output format") ErrNotRenderable = errors.New("value cannot be rendered") )
var Formats = []string{ string(FormatTable), string(FormatJSON), string(FormatYAML), string(FormatXML), "custom-columns=NAME:.field,...", }
Functions ¶
Types ¶
type Column ¶
type Column struct {
Header string
Path []step
}
Column is one user-defined table column, as in -o custom-columns=NAME:.name,SIZE:.size_gb
The syntax follows kubectl's, deliberately: it is the one people already know, and it is small enough to specify exactly — a dotted field path with optional array indices, not general JSONPath.
func ParseColumns ¶
ParseColumns reads `HEADER:.path,HEADER:.path`.
type Printer ¶
type Printer struct {
Format Format
// Columns, when set, replaces the automatic column choice for table output.
Columns []Column
Out io.Writer
// Width is the terminal width used to decide how many columns fit. Zero
// means unknown, and then a fixed cap applies instead.
Width int
// Notice receives a line about anything hidden, on stderr, so that stdout
// stays exactly the table.
Notice io.Writer
// Root names the outermost XML element. A reply is an unnamed value and XML
// has no way to write one, so something has to be chosen; a caller that knows
// what it asked for can say so instead of taking "result".
Root string
}
func (*Printer) Print ¶
Print renders one value in the selected format.
Everything is normalised first, so all three formats describe the same value and convert into each other losslessly. Without it, a Go struct would render under its json tags via -o json and its yaml tags via -o yaml, giving two different field names for one field.