Documentation
¶
Overview ¶
Package termoutput 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 termstyle.Scheme) error
- func TableWith(w io.Writer, tv TableValue, scheme termstyle.Scheme) error
- func YAML(w io.Writer, v any) (err 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. Non-finite values are marked ? and ignored when computing the axis.
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 ¶
TableStyle renders with an explicit termtable style: StyleBordered (bordered, the default look) or StyleBorderless (borderless, most script-friendly).
func TableStyleWith ¶
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.