Help us shape the future of Go! Take the 2026 Go Developer Survey

output

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package output implements the versioned JSON envelope and error taxonomy.

Contract: stdout carries exactly one JSON document per invocation when --json is set. Diagnostics go to stderr only.

Index

Constants

View Source
const (
	ExecNone      = "not_submitted"
	ExecUnknown   = "unknown"
	ExecRejected  = "rejected"
	ExecSubmitted = "submitted"
)

Execution states reported for mutating commands.

View Source
const SchemaVersion = "oku.cli/v1"

SchemaVersion identifies the stdout JSON contract.

Variables

This section is empty.

Functions

func NewRequestID

func NewRequestID() string

NewRequestID returns a random 128-bit hex id.

func Write

func Write(w io.Writer, env Envelope) error

Write encodes the envelope to w.

Types

type Code

type Code string

Code is a stable, documented error code.

const (
	CodeUsage                Code = "USAGE"
	CodeInvalidArgument      Code = "INVALID_ARGUMENT"
	CodeInvalidDecimal       Code = "INVALID_DECIMAL"
	CodeNetworkMismatch      Code = "NETWORK_MISMATCH"
	CodeNetworkUnsupported   Code = "NETWORK_UNSUPPORTED"
	CodeAccountRequired      Code = "ACCOUNT_REQUIRED"
	CodeProfileNotFound      Code = "PROFILE_NOT_FOUND"
	CodeConfigError          Code = "CONFIG_ERROR"
	CodeAuthRequired         Code = "AUTH_REQUIRED"
	CodeAuthUnavailable      Code = "AUTH_UNAVAILABLE"
	CodeSignerUnavailable    Code = "SIGNER_UNAVAILABLE"
	CodeKeychainLocked       Code = "KEYCHAIN_LOCKED"
	CodeKeychainAccessDenied Code = "KEYCHAIN_ACCESS_DENIED"
	CodeKeychainCanceled     Code = "KEYCHAIN_CANCELED"
	CodeSignerRejected       Code = "SIGNER_REJECTED"
	CodeApprovalRequired     Code = "APPROVAL_REQUIRED"
	CodePayloadMismatch      Code = "PAYLOAD_MISMATCH"
	CodeUpstream             Code = "UPSTREAM_ERROR"
	CodeUpstreamTimeout      Code = "UPSTREAM_TIMEOUT"
	CodeRateLimited          Code = "RATE_LIMITED"
	CodeNotFound             Code = "NOT_FOUND"
	CodeOutcomeUnknown       Code = "OUTCOME_UNKNOWN"
	CodeInsufficientGas      Code = "INSUFFICIENT_GAS"
	CodeInsufficientBalance  Code = "INSUFFICIENT_BALANCE"
	CodeIntentConflict       Code = "INTENT_CONFLICT"
	CodeIntentState          Code = "INTENT_STATE"
	CodeRejected             Code = "REJECTED"
	CodeConflict             Code = "FILE_EXISTS"
	CodeInternal             Code = "INTERNAL"
)

func (Code) ExitCode

func (c Code) ExitCode() int

ExitCode maps an error code to the process exit status.

type Envelope

type Envelope struct {
	SchemaVersion string `json:"schema_version"`
	RequestID     string `json:"request_id"`
	Command       string `json:"command"`
	OK            bool   `json:"ok"`
	Data          any    `json:"data"`
	Error         *Error `json:"error"`
}

Envelope is the stdout JSON document.

type Error

type Error struct {
	Code           Code           `json:"code"`
	Message        string         `json:"message"`
	Retryable      bool           `json:"retryable"`
	ExecutionState string         `json:"execution_state,omitempty"`
	Details        map[string]any `json:"details,omitempty"`
	// contains filtered or unexported fields
}

Error is a structured CLI error.

func As

func As(err error) *Error

As converts any error to *Error.

func Errorf

func Errorf(code Code, format string, args ...any) *Error

Errorf builds an Error.

func Wrap

func Wrap(code Code, err error, msg string) *Error

Wrap builds an Error with a cause.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithDetail

func (e *Error) WithDetail(k string, v any) *Error

WithDetail adds a detail field.

func (*Error) WithExec

func (e *Error) WithExec(state string) *Error

WithExec sets the execution state.

func (*Error) WithRetry

func (e *Error) WithRetry() *Error

WithRetry marks the error retryable.

Jump to

Keyboard shortcuts

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