output

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitOK        = 0
	ExitUsage     = 1
	ExitNotFound  = 2
	ExitAuth      = 3
	ExitForbidden = 4
	ExitRateLimit = 5
	ExitNetwork   = 6
	ExitAPI       = 7
	ExitAmbiguous = 8
)

Variables

View Source
var (
	ErrUsage     = apierr.ErrUsage
	ErrUsageHint = apierr.ErrUsageHint
	ErrNotFound  = apierr.ErrNotFound
	ErrAuth      = apierr.ErrAuth
	ErrForbidden = apierr.ErrForbidden
	ErrRateLimit = apierr.ErrRateLimit
	ErrNetwork   = apierr.ErrNetwork
	ErrAPI       = apierr.ErrAPI
	ErrAmbiguous = apierr.ErrAmbiguous
	AsError      = apierr.AsError
)

Functions

func ExitCodeFor

func ExitCodeFor(err error) int

func NormalizeJSONNumbers

func NormalizeJSONNumbers(data []byte) (any, error)

func TruncationNotice

func TruncationNotice(shown, total int) string

func TruncationNoticeWithCmd

func TruncationNoticeWithCmd(shown, total int, cmd string) string

func ValidateJQFilter added in v0.1.1

func ValidateJQFilter(filter string) error

ValidateJQFilter confirms that a built-in jq expression is ready to run.

Types

type Breadcrumb struct {
	Action      string `json:"action"`
	Command     string `json:"command"`
	Description string `json:"description"`
}

type Error

type Error = apierr.Error

Error is a typed error with a code, message, and optional fields. Alias for apierr.Error so that cmd-layer code can use output.Error without importing the domain package directly.

func ErrJQConflict added in v0.1.1

func ErrJQConflict(flag string) *Error

ErrJQConflict reports an output flag that cannot be combined with --jq.

func ErrJQNotSupported added in v0.1.1

func ErrJQNotSupported(command string) *Error

ErrJQNotSupported reports a command that produces a dedicated raw format.

func ErrJQRuntime added in v0.1.1

func ErrJQRuntime(cause error) *Error

ErrJQRuntime reports a failure while evaluating a built-in jq expression.

func ErrJQValidation added in v0.1.1

func ErrJQValidation(cause error) *Error

ErrJQValidation reports an invalid built-in jq expression.

type ErrorResponse

type ErrorResponse struct {
	OK    bool           `json:"ok"`
	Error string         `json:"error"`
	Code  string         `json:"code"`
	Hint  string         `json:"hint,omitempty"`
	Meta  map[string]any `json:"meta,omitempty"`
}

type Format

type Format int
const (
	FormatAuto Format = iota
	FormatJSON
	FormatStyled
	FormatQuiet
	FormatIDs
	FormatCount
	FormatMarkdown
)

func FormatFromFlags

func FormatFromFlags(jsonFlag, quiet, idsOnly, count, markdown, styled, agent bool) Format

type Options

type Options struct {
	Format   Format
	Stdout   io.Writer
	Stderr   io.Writer
	JQFilter string
}

type Response

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

type ResponseOption

type ResponseOption func(*Response)

func WithBreadcrumbs

func WithBreadcrumbs(b ...Breadcrumb) ResponseOption

func WithMeta

func WithMeta(key string, value any) ResponseOption

func WithNotice

func WithNotice(s string) ResponseOption

func WithSummary

func WithSummary(s string) ResponseOption

type Writer

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

func New

func New(opts Options) *Writer

func (*Writer) EffectiveFormat

func (w *Writer) EffectiveFormat() Format

func (*Writer) Err

func (w *Writer) Err(err error)

func (*Writer) IsStyled

func (w *Writer) IsStyled() bool

func (*Writer) OK

func (w *Writer) OK(data any, opts ...ResponseOption) error

Jump to

Keyboard shortcuts

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