Documentation
¶
Overview ¶
Package output prints command results: tables, JSON, YAML, ASCII graphs, human sizes, and shell-split command lines.
Tables use ASCII borders only, so output is byte-identical on Linux, macOS, and legacy Windows consoles. JSON and YAML marshal with stable key order for golden tests and pipes.
Index ¶
- Constants
- func Bytes(n uint64) string
- func Graph(values []float64) string
- func IBytes(n uint64) string
- func JSON(w io.Writer, v any) error
- func Render(w io.Writer, format string, v any) error
- func Split(s string) ([]string, error)
- func Table(w io.Writer, header []string, rows [][]string) error
- func TableStyle(w io.Writer, tv TableValue, s termtable.Style) error
- func TableStyleWith(w io.Writer, tv TableValue, s termtable.Style, scheme style.Scheme) error
- func TableWith(w io.Writer, tv TableValue, scheme style.Scheme) error
- func YAML(w io.Writer, v any) error
- type TableValue
Constants ¶
const ( FormatTable = "table" FormatJSON = "json" FormatYAML = "yaml" )
Formats for Render and the --output flag.
Variables ¶
This section is empty.
Functions ¶
func Graph ¶
Graph renders values as a plain-ASCII point chart with a labeled axis: pure ASCII, no color codes, safe on every console including raster fonts.
func JSON ¶
JSON writes indented JSON plus a trailing newline. Map keys marshal in sorted order, so output is stable across runs.
func Render ¶
Render writes v in the named format: table, json, or yaml. Tables need a header plus string rows: pass TableValue{Header, Rows}. Anything else returns an error (app validates --output earlier too).
func TableStyle ¶ added in v1.1.1
TableStyle renders with an explicit termtable style: StyleBordered (bordered, the default look) or StyleBorderless (borderless, most script-friendly).
func TableStyleWith ¶ added in v1.2.1
TableStyleWith renders like TableStyle but styles the header through scheme, on any termtable style. Borderless and grid styles both measure visible width, so styled headers stay aligned either way.
Types ¶
type TableValue ¶
TableValue carries a table for Render.