output

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderError

func RenderError(w io.Writer, format Format, jqExpr string, envelope ErrorEnvelope) error

func RenderSuccess

func RenderSuccess(w io.Writer, format Format, jqExpr string, envelope SuccessEnvelope) error

Types

type ErrorDetail

type ErrorDetail struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	Hint      string `json:"hint,omitempty"`
	Retryable bool   `json:"retryable"`
	Details   any    `json:"details,omitempty"`
}

type ErrorEnvelope

type ErrorEnvelope struct {
	OK     bool           `json:"ok"`
	Error  ErrorDetail    `json:"error"`
	Notice map[string]any `json:"_notice,omitempty"`
	Meta   Meta           `json:"meta"`
}

type ExitError

type ExitError struct {
	Code   int
	Detail ErrorDetail
}

func NewExitError

func NewExitError(code string, exitCode int, message string, hint string) *ExitError

func (*ExitError) Error

func (e *ExitError) Error() string

type Format

type Format string
const (
	FormatJSON   Format = "json"
	FormatPretty Format = "pretty"
	FormatNDJSON Format = "ndjson"
	FormatTable  Format = "table"
)

func NormalizeFormat

func NormalizeFormat(raw string) (Format, error)

type IdentityMeta

type IdentityMeta struct {
	Name string `json:"name,omitempty"`
	DID  string `json:"did,omitempty"`
}

type Meta

type Meta struct {
	Version  string        `json:"version"`
	Identity *IdentityMeta `json:"identity,omitempty"`
	DryRun   bool          `json:"dry_run"`
	Format   string        `json:"format"`
}

type SuccessEnvelope

type SuccessEnvelope struct {
	OK       bool           `json:"ok"`
	Command  string         `json:"command"`
	Data     any            `json:"data,omitempty"`
	Warnings []string       `json:"warnings,omitempty"`
	Summary  string         `json:"summary,omitempty"`
	Notice   map[string]any `json:"_notice,omitempty"`
	Meta     Meta           `json:"meta"`
}

Jump to

Keyboard shortcuts

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