cmdutil

package
v0.0.2-testing Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 4 Imported by: 1 module, 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 (
	ExitOK       = 0
	ExitError    = 1
	ExitUsage    = 2
	ExitAuth     = 4
	ExitNotFound = 5
	ExitCancel   = 8
)

Exit codes. Keep in sync with sdk/corecmd/topics/exit-codes.txt and sdk/skills/SKILL.md.tmpl.

Variables

View Source
var ErrCancel = &Error{Exit: ExitCancel, Code: "cancelled", Message: "cancelled"}

ErrCancel is returned when the user aborts an operation.

Functions

func ExitCode

func ExitCode(err error) int

ExitCode maps an error to a process exit code.

Types

type Error

type Error struct {
	Exit    int    `json:"-"`
	Code    string `json:"code"`
	Message string `json:"message"`
	Hint    string `json:"hint,omitempty"`
	Err     error  `json:"-"`
	// Silent means the command already reported the problem; only the exit code matters.
	Silent bool `json:"-"`
}

Error is a user-facing error with a stable machine-readable code and an optional hint.

func AsError

func AsError(err error) *Error

AsError converts any error into an *Error for structured reporting.

func FlagErrorf

func FlagErrorf(format string, args ...any) *Error

FlagErrorf reports invalid usage (exit code 2).

func NewError

func NewError(exit int, code, message, hint string) *Error

NewError creates an *Error.

func NoInputError

func NoInputError(what, flag string) *Error

NoInputError is returned when a value is required but prompting is not possible.

func NotFoundf

func NotFoundf(format string, args ...any) *Error

NotFoundf reports a missing resource (exit code 5).

func SilentExit

func SilentExit(exit int, code string) *Error

SilentExit returns an error that only sets the exit code.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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