output

package
v0.0.0-...-9239525 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// Input: CLI flag and argument validation.
	ErrInputMissing  = "INPUT_001" // required flag or argument not provided
	ErrInputConflict = "INPUT_002" // mutually exclusive flags used together
	ErrInputInvalid  = "INPUT_003" // flag value is invalid (wrong format, out of range)
	ErrInputTerminal = "INPUT_004" // command requires interactive terminal
)

Error code constants. Each code is namespaced by category and numbered. Format: CATEGORY_NNN

View Source
const (
	ExitSuccess = 0 // Success
	ExitError   = 1 // General error
	ExitUsage   = 2 // Usage error (invalid arguments, missing config, etc.)
	ExitDrift   = 3 // Drift detected (drift command only)
)

Exit codes for consistent scripting behavior.

Variables

View Source
var (
	JSON      bool      // set from --json flag
	Quiet     bool      // set from --quiet flag
	Verbose   bool      // set from --verbose flag
	Writer    io.Writer = os.Stdout
	ErrWriter io.Writer = os.Stderr
)

Functions

func AllErrorCodes

func AllErrorCodes() []string

AllErrorCodes returns all registered error code values for validation. Used by tests to assert uniqueness and format correctness.

func IsSilentError

func IsSilentError(err error) bool

IsSilentError checks if an error is marked as already printed.

func Print

func Print(v any)

func PrintError

func PrintError(code int, message, suggestion string)

func PrintStructuredError

func PrintStructuredError(e StructuredError)

PrintStructuredError prints a StructuredError to ErrWriter. In JSON mode, prints structured JSON. In plain mode, prints human-readable format.

func PrintVerbose

func PrintVerbose(format string, args ...any)

PrintVerbose prints only when Verbose is true.

func SetForTest

func SetForTest(t interface{ Cleanup(func()) }) (stdout, stderr *bytes.Buffer)

SetForTest saves current global state and returns test-safe writers. It registers a cleanup function via t.Cleanup to restore all globals after the test completes (even if the test panics).

Returns (stdout, stderr) buffers that are also set as Writer/ErrWriter.

func SilentError

func SilentError(err error) error

SilentError wraps an error to mark it as already printed.

Types

type ErrorResponse

type ErrorResponse struct {
	Code       int    `json:"code"`
	Message    string `json:"message"`
	Suggestion string `json:"suggestion,omitempty"`
}

type StructuredError

type StructuredError struct {
	Code       string `json:"code"`
	Message    string `json:"message"`
	Suggestion string `json:"suggestion,omitempty"`
	Details    string `json:"details,omitempty"`
}

StructuredError is a machine-readable error with a namespaced code.

func NewStructuredError

func NewStructuredError(code, message, suggestion string) StructuredError

NewStructuredError creates a StructuredError with Code, Message, and Suggestion.

func (StructuredError) Error

func (e StructuredError) Error() string

Error implements the error interface so StructuredError works with errors.As().

Jump to

Keyboard shortcuts

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