output

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorWasRendered

func ErrorWasRendered() bool

ErrorWasRendered reports whether any Writer.Err has been called in this process. Intended for the CLI entrypoint to suppress double-printing.

Types

type Breadcrumb struct {
	Action      string `json:"action"`
	Cmd         string `json:"cmd"`
	Description string `json:"description"`
}

Breadcrumb suggests a follow-up action to the user or agent.

type ErrorResponse

type ErrorResponse struct {
	OK    bool   `json:"ok"`
	Error string `json:"error"`
	Code  string `json:"code,omitempty"`
	Hint  string `json:"hint,omitempty"`
}

ErrorResponse is the JSON envelope for errors.

type Format

type Format int

Format represents the output format.

const (
	FormatAuto  Format = iota // Styled if TTY, JSON if piped
	FormatJSON                // JSON with envelope
	FormatAgent               // Raw JSON data only (--agent = --json + --quiet)
	FormatQuiet               // Minimal output
	FormatIDs                 // IDs only, one per line
	FormatCount               // Just the count
)

type Response

type Response struct {
	OK          bool         `json:"ok"`
	Data        any          `json:"data"`
	Summary     string       `json:"summary,omitempty"`
	Breadcrumbs []Breadcrumb `json:"breadcrumbs,omitempty"`
}

Response is the standard JSON envelope for successful responses.

type Writer

type Writer struct {
	Format Format
}

Writer handles output formatting based on the selected format.

func NewWriter

func NewWriter(format Format) *Writer

NewWriter creates an output writer. Defaults to auto-detection.

func (*Writer) Err

func (w *Writer) Err(err error, code, hint string)

Err outputs an error and marks the process as having rendered one (see ErrorWasRendered).

func (*Writer) OK

func (w *Writer) OK(data any, summary string, breadcrumbs []Breadcrumb)

OK outputs a successful result.

Jump to

Keyboard shortcuts

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