cli

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 63 Imported by: 0

Documentation

Overview

Package cli builds the lo command tree.

Index

Constants

View Source
const (
	AnnotationDestructive = "lok8s.dev/destructive"
	AnnotationReadonly    = "lok8s.dev/readonly"
	AnnotationIdempotent  = "lok8s.dev/idempotent"
)

Annotation keys carried on every command. They mirror the argsh usage markers (`@destructive`, `@readonly`, `@idempotent`) and drive confirmation gating and MCP tool filtering.

Variables

View Source
var ErrCheckFailed = ErrHandled

ErrCheckFailed is the `--check` verdict: something would be ejected, or something drifted. main prints nothing for it (the command already did) and exits 1.

View Source
var ErrHandled = ui.ErrHandled // one sentinel for every package; see internal/ui

ErrHandled marks an error whose message was already printed in the bash implementation's own format ([error] … on stderr). The caller exits non-zero without printing anything further.

Functions

func NewRoot

func NewRoot(paths *config.Paths) *cobra.Command

NewRoot builds the full lo command tree: the usage-mirrored tree plus the Go-only commands. The project's spec.implementation (routing.go) is read once here: a routed command is registered as a shim to the bash tree in the project, `default: bash` shims the whole usage tree, and the Go-only commands stay Go.

func Shim

func Shim(p *config.Paths, argv []string) error

Shim replaces the current process with the argsh implementation (`lo` in the bash tree), passing argv through verbatim so both implementations parse identically. The tree is a checkout or ejected tree when the project has one, else the copy embedded in the binary, extracted once into the versioned cache (assets.BashTree). This is the `lo drivers <name>` fallback for a driver without a Go twin; a routed command (routing.go) goes through execShim with the project's tree instead and never reaches the cache.

func WatchInterrupt

func WatchInterrupt(parent context.Context) (ctx context.Context, exitCode func() int)

WatchInterrupt cancels the returned context on the first SIGINT or SIGTERM and reports the exit code that signal maps to. The bash entrypoint set no trap: the shell died of the signal, the process exit code was 128+n (130 for SIGINT, 143 for SIGTERM) and nothing was printed. The Go binary cancels the command context instead, so every Runner child and every wait loop stops, and main exits with the same code. The watch ends with the first signal: a second one takes the default action again and ends a process that did not stop on its own.

exitCode stops the watch and returns 0 while no signal arrived, else 128+n. Call it once, after the command returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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