Documentation
¶
Overview ¶
Package format is the tiny output abstraction used by ebctl commands. Each command builds a "row set" or a single value, hands it to a Printer, and the Printer decides whether to render a pretty table or JSON.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HumanDuration ¶
HumanDuration is a compact rendering shared by table rows.
Types ¶
type JSONPrinter ¶
type JSONPrinter struct{}
JSONPrinter emits newline-delimited JSON blocks.
func (JSONPrinter) Name ¶
func (JSONPrinter) Name() string
type PrettyPrinter ¶
type PrettyPrinter struct{}
PrettyPrinter renders tab-aligned tables and human text.
func (PrettyPrinter) Name ¶
func (PrettyPrinter) Name() string
type Printer ¶
type Printer interface {
// Table renders a headered table of rows. Ignored by JSON printer
// (which uses Value instead).
Table(w io.Writer, headers []string, rows [][]string) error
// Value emits a single structured value. Pretty printer falls back to
// fmt.Fprintf; JSON printer marshals.
Value(w io.Writer, v any) error
// Text emits a human-readable string. JSON printer wraps it as {"text": ...}.
Text(w io.Writer, s string) error
// Name returns the printer's canonical name ("pretty" or "json").
Name() string
}
Printer is implemented by PrettyPrinter and JSONPrinter.
Click to show internal directories.
Click to hide internal directories.