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), "custom-columns=NAME:.field,...", }
Functions ¶
func Normalize ¶
Normalize converts any value into the JSON data model — map[string]any, []any, string, float64, bool, nil.
Replies decoded from a service are already in it. Commands that build their own output (auth status, project list, spec list) hand over Go structs, and this is where they join the same pipeline, so -o json works for them exactly as it does for a passthrough call.
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
}
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.