Documentation
¶
Overview ¶
Package output renders command results in the three formats every weg command supports: human-readable text, JSON and YAML.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownFormat = errors.New("unknown output format")
ErrUnknownFormat is returned when a format string is not one of the supported values.
Functions ¶
func ColorEnabled ¶
ColorEnabled reports whether colour output is appropriate for w.
func Formats ¶
func Formats() []string
Formats lists the supported formats, for flag help and shell completion.
func IsTerminal ¶
IsTerminal reports whether f is backed by a character device.
Types ¶
type Color ¶
type Color string
Color is a terminal colour, as the SGR parameter that selects it.
TODO: Lipgloss is the eventual home for this, once there is a table to draw with it. Until then a handful of escape sequences is less than a dependency, and having them here rather than in a command is what keeps the NO_COLOR and TTY rules in one place.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer renders command results to a writer in a chosen format.
func New ¶
New returns a Printer writing to out, with errors and diagnostics going to errOut. Colour is enabled only when the format is text and out is a terminal that has not opted out; see ColorEnabled.
func (*Printer) Color ¶
Color reports whether colour escape sequences should be emitted.
Commands must consult this rather than deciding for themselves, so that NO_COLOR and non-terminal output are honoured consistently.