Documentation
¶
Overview ¶
Package output provides stable JSON envelope construction, JSON serialization, and human-readable table rendering for canvas-cli commands.
Index ¶
- Constants
- func ExitCodeForCategory(category string) int
- func NewError(err *canvas.ErrorInfo, command string, metaOverrides ...canvas.Meta) canvas.Envelope
- func NewSuccess(data any, command string, metaOverrides ...canvas.Meta) canvas.Envelope
- func WriteJSON(w io.Writer, envelope *canvas.Envelope, pretty bool) error
- type Table
Constants ¶
const ( CodeSuccess = 0 CodeGenericError = 1 CodeValidationError = 2 CodeAuthError = 3 CodePermissionDenied = 4 CodeRateLimit = 5 CodeNetworkError = 6 CodeSafetyBlocked = 7 CodePartialFailure = 8 )
Exit codes matching the taxonomy in docs/json-contract.md.
const SchemaVersion = canvas.SchemaVersion
SchemaVersion is re-exported from the canvas package for convenience.
Variables ¶
This section is empty.
Functions ¶
func ExitCodeForCategory ¶ added in v0.4.0
ExitCodeForCategory maps a JSON error category to a process exit code. Unknown categories map to CodeGenericError.
func NewError ¶
NewError builds an error Envelope with ok=false. Every envelope carries a fresh request_id (uuid v4). Optional meta overrides are merged onto the base Meta.
func NewSuccess ¶
NewSuccess builds a success Envelope with ok=true and the given data. Every envelope carries a fresh request_id (uuid v4). Optional meta overrides are merged onto the base Meta.