cmd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitOK       = 0
	ExitError    = 1 // generic error not covered below
	ExitUsage    = 2 // unknown command/flag or bad arg count
	ExitNotRepo  = 3 // cwd is not a drift repository
	ExitNetwork  = 4 // network error (upgrade, push, pull, clone, ls-remote)
	ExitConflict = 5 // workspace locked, branch/tag already exists, etc.
)

Exit codes returned by Execute. They are intentionally stable so that scripts and shell pipelines can branch on them. The names mirror the failure category, not the specific sentinel, so additional sentinels can be added without breaking the contract.

Variables

View Source
var ErrSilent = errors.New("silent error (already reported)")

ErrSilent indicates that an error was already displayed to the user via statusFailed, and Execute() should exit with code 1 without printing the error again.

Functions

func Execute

func Execute() int

Execute runs the root command and returns a process exit code. The caller (main) should pass the return value to os.Exit. Errors are classified by sentinel identity so scripts can branch on ExitNotRepo, ExitNetwork, ExitConflict, etc. ErrSilent means the error was already displayed via reportFailed; it maps to ExitError.

Types

type JSONEnvelope

type JSONEnvelope struct {
	Command     string      `json:"command"`
	Status      string      `json:"status"`                 // ok / failed / warning / active
	Error       string      `json:"error,omitempty"`        // error message when status == "failed"
	ErrorDetail string      `json:"error_detail,omitempty"` // verbose: underlying error cause
	Data        interface{} `json:"data,omitempty"`
	Hint        *string     `json:"hint"`
}

JSONEnvelope is the unified output envelope for --json mode. All commands supporting --json emit this structure so that scripts can parse a single schema regardless of the command. Hint is a pointer so that an absent hint serializes as JSON null (per docs/cli-design.md), matching the design's "hint": null example, rather than being omitted. ErrorDetail is populated only when --verbose is set and an underlying error is available, so scripts can access the real error cause.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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