Documentation
¶
Index ¶
Constants ¶
const ( Table = "table" JSON = "json" YAML = "yaml" )
Variables ¶
This section is empty.
Functions ¶
func ResourceColumns ¶
ResourceColumns returns a copy of the declared per-resource column lists, for tests that check every declared column exists in the spec.
func Sanitize ¶
Sanitize makes API-controlled text safe to print to a terminal.
A customer name is whatever the caller sent Lago, and a table cell prints it raw. QA created a customer whose name held an ANSI colour sequence and a newline: the escape recoloured the terminal and the newline injected a fake row. Every C0 and C1 control character (ESC, CR, LF, TAB, NUL, DEL, 0x80-0x9f) is therefore replaced by its visible escape, `\x1b`, `\n`, `\r`, `\t`, `\xNN`, and an invalid UTF-8 byte by `\xNN`. Replacing rather than stripping keeps the evidence: an operator sees that the name contains an escape instead of a silently shortened string. Printable text, including non-ASCII, is untouched. --output json is unaffected; encoding/json escapes on its own.
func WritePairs ¶
WritePairs prints pairs in the order given, as the table renderer prints a resource: upper-case key, two-space gap, sanitised value. Blank values are skipped. Built-in commands whose output is a short identity block (`whoami`) use it so the order is the one a reader expects rather than alphabetical.
Types ¶
type Renderer ¶
type Renderer struct {
Mode string
Query string
Out io.Writer
// Err receives diagnostics that must not pollute stdout: the hint printed when a
// query matches nothing, and the paging hint under a partial list. Leaving it nil
// discards them.
Err io.Writer
// Identifiers restricts default table output to the terse identifier block.
// It applies to table output only: --output json and --output yaml always
// carry the complete resource. See DECISIONS.md.
Identifiers bool
// AllPages is set by --all, which renders every page itself, so the per-page
// "page N of M" hint would only be noise.
AllPages bool
}