Documentation
¶
Overview ¶
Package printer turns results into output.
One decision is made once, here, and everything else follows from it: is this output for a person or for a program? A terminal gets styled tables and rendered markdown; a pipe gets plain text, no escape codes, aligned columns awk can split. Commands never ask that question themselves, so no command can answer it differently.
The styled and plain paths lay columns out identically — only styling differs — so a screenshot and a pasted pipe show the same shape. Two renderers exist because ANSI escapes break byte-counting alignment: text/tabwriter is correct when there are no escapes, lipgloss is correct when there are.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Color ¶
Color reports whether output to w should be styled.
Styling is opt-out in three independent ways because each covers a case the others miss: --no-color is the explicit ask, NO_COLOR is the cross-tool convention, and a non-terminal writer means nobody is reading this with their eyes. TERM=dumb catches terminals that cannot render it.
Types ¶
type Doc ¶
type Doc struct {
// contains filtered or unexported fields
}
Doc builds the detail views — what `describe` and `review` print.
Commands declare structure (a section, a field, a body of markdown) and never formatting. The same declarations render as styled terminal output or as markdown depending only on the printer's format, which is why `patchy review -o markdown` pastes cleanly into an issue without a second code path.
func (*Doc) Body ¶
Body adds a block of markdown to the current section — an agent report, a summary paragraph.
func (*Doc) Field ¶
Field adds a key/value line to the current section. An empty value is skipped: a detail view listing a dozen "<none>" rows buries the handful of fields that actually say something.
type Format ¶
type Format string
Format is an output shape.
const ( // FormatTable is the default: the server-rendered print columns. FormatTable Format = "table" // FormatWide adds the CRD's priority>0 columns. FormatWide Format = "wide" // FormatJSON emits the objects verbatim. FormatJSON Format = "json" // FormatYAML emits the objects verbatim. FormatYAML Format = "yaml" // FormatName emits `<resource>.<group>/<name>` lines, for xargs. FormatName Format = "name" // FormatMarkdown emits markdown — a table for lists, prose for reports. // This is the paste-into-a-ticket format, so it is never styled. FormatMarkdown Format = "markdown" )
The output formats. table and wide differ only in whether the CRD's lower-priority print columns are included.
func (Format) Structured ¶
Structured reports whether the format is machine-facing, in which case commands emit whole objects rather than a human summary.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer writes command results in one format.
func (*Printer) Format ¶
Format reports the printer's format, for commands that shape their own output (describe, review).
func (*Printer) Markdown ¶
Markdown writes a markdown document: rendered for a terminal, verbatim otherwise. "Otherwise" covers both a pipe and -o markdown, which is the point — the bytes a user pastes into an issue are the bytes the agent wrote.