Documentation
¶
Overview ¶
Package listfmt — small renderer used by every `clawtool * list` subcommand (bridges, agents, sources, recipes, sandboxes, portals, hooks, …). Repowire pattern: each list command accepts `--format json|tsv|table` (default: table) and the renderer outputs in the requested shape so shell pipes get machine-readable rows without needing `awk` to peel a human-formatted table.
Usage:
listfmt.Render(stdout, "table", listfmt.Cols{
Header: []string{"FAMILY", "STATUS", "DESCRIPTION"},
Rows: [][]string{{"codex", "ready", "..."}, ...},
})
`format` is parsed once by the caller — either via listfmt.Parse(argv) which strips `--format X` from a flag slice, or by the caller's own arg parser. listfmt itself is pure rendering.
Index ¶
Constants ¶
const DefaultFormat = FormatTable
DefaultFormat is what every list command falls back to when no `--format` flag is given. Table is the right default for interactive shell use; pipes / scripts can opt into tsv or json.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cols ¶
Cols is a small column-row container the renderer takes. Header names should be UPPERCASE for table mode (matches existing clawtool list output convention) and stay UPPERCASE for tsv too — JSON mode lower-cases them to produce idiomatic keys.
type Format ¶
type Format string
Format enumerates the supported output shapes.
func ExtractFlag ¶
ExtractFlag pulls `--format <value>` (or `--format=<value>`) out of argv and returns (format, residual argv, error). Empty argv → (DefaultFormat, argv, nil). Unknown value is preserved verbatim — the caller decides whether to error or degrade.
Repeated `--format` is allowed; the last one wins (matches most CLI conventions where late flags override early ones).
func ParseFormat ¶
ParseFormat normalises a string into a known Format. Empty, unknown values, and the defaults all collapse to FormatTable. Callers that want to reject unknowns can compare against IsKnown() first.