output

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package output implements the CLI's machine-readable stdout contract.

Index

Constants

View Source
const (
	FormatJSON = "json"
	FormatText = "text"
	FormatRaw  = "raw"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CLIError

type CLIError struct {
	Code    string
	Message string
	Details map[string]any
	Cause   error
}

CLIError is a stable E_* error with its canonical exit and retry semantics.

func NewError

func NewError(code, message string, details map[string]any) *CLIError

func WrapError

func WrapError(code, message string, cause error, details map[string]any) *CLIError

func (*CLIError) Error

func (e *CLIError) Error() string

func (*CLIError) ExitCode

func (e *CLIError) ExitCode() int

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

type Options

type Options struct {
	Format    string
	Compact   bool
	Fields    []string
	StartedAt time.Time
	Notices   []any
}

Options controls one command invocation's output.

type Printer

type Printer struct {
	// contains filtered or unexported fields
}

Printer writes exactly one command result to stdout.

func NewPrinter

func NewPrinter(out io.Writer, options Options) *Printer

func (*Printer) Failure

func (p *Printer) Failure(cliErr *CLIError) error

func (*Printer) Raw

func (p *Printer) Raw(data []byte) error

func (*Printer) Success

func (p *Printer) Success(data any) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL