Documentation
¶
Overview ¶
Package cliout renders user-facing CLI output.
Today it owns one function — WriteError — which formats any error into the foundation's standard stderr template:
Error: <one-line summary> What to do: • <remediation step> • <additional remediation step if applicable> [exit <exit_code>: <ERROR_CODE>]
The "What to do" block is omitted when the error has no remediation bullets (typically *errcode.Error with empty Help, e.g. recovered panics). The footer line is always present and is always the last non-empty line written.
Errors that are not *errcode.Error are surfaced as INTERNAL_ERROR with the underlying error message as the summary — this catches unanticipated failures and routes them through the same contract.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTTY ¶
IsTTY reports whether w writes to a terminal. Callers MUST use this before emitting ANSI colour codes or carriage-return-driven progress animations to honour the stdout/stderr-discipline contract in openspec/changes/pivot-to-ai-as-code/specs/cli-framework/spec.md.
The detection only succeeds for *os.File writers; any other writer type (bytes.Buffer in tests, a strings.Builder, a pipe, etc.) is treated as non-TTY. This is conservative on purpose — when in doubt, emit plain bytes so AI consumers and shell pipelines see exactly what the spec promises.
func WriteError ¶
WriteError writes the standard error template to w. If err is nil, WriteError is a no-op.
The template is assembled in a strings.Builder and flushed to w in a single Write so the function has exactly one I/O boundary to ignore (Stderr writes are best-effort — if the OS refuses, there is nothing useful to do at this layer).
Types ¶
This section is empty.