Documentation
¶
Overview ¶
Package output renders command results for either agents or humans. JSON is the default (machine-readable); table is human-friendly; ndjson streams one record per line for large result sets.
Index ¶
Constants ¶
const ( FormatJSON = "json" FormatTable = "table" FormatNDJSON = "ndjson" )
Format identifies an output format.
Variables ¶
This section is empty.
Functions ¶
func EmitError ¶
EmitError writes a structured error as JSON to w (typically stderr). When the process was invoked with --pretty AND w is a TTY, the error JSON is also colorized; otherwise it falls back to plain JSON so log scrapers and non-TTY consumers see byte-identical output.
func EmitList ¶
EmitList renders a paginated list result as a {items, next, has_more} envelope. Unlike Emit it is told explicitly that the value is a list, so the envelope shape never has to be guessed from the data. json emits the envelope; table renders the items as a grid with a cursor footer; ndjson streams the items, one per line.
func EmitNotice ¶
EmitNotice writes a single compact JSON line carrying out-of-band notices (e.g. a newer-release notice, or input corrections) to w — typically stderr. It deliberately never touches stdout, so the command's data contract on stdout stays byte-identical; agents still see the notice via the shell. Failures are swallowed: a notice must never turn a successful command into a failure.
func SetErrorPretty ¶
func SetErrorPretty(v bool)
SetErrorPretty toggles the process-global pretty flag for EmitError. It is called by the root command after parsing --pretty so error output styling matches success output styling.
Types ¶
type Options ¶
type Options struct {
Format string
// Fields, when non-empty, projects each record to these dot-path keys.
Fields []string
Writer io.Writer
// Pretty enables ANSI-colored JSON when Writer is a TTY. It has no effect
// on table output and is silently downgraded to plain JSON when Writer is
// not a terminal (so e.g. `--pretty | jq` continues to work).
Pretty bool
}
Options configures rendering.