cli

package
v0.10.18 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommandsTo

func AddCommandsTo(root *cobra.Command)

AddCommandsTo registers every CLI subcommand onto the supplied root command and attaches global persistent flags shared by all subcommands.

func ExitCode added in v0.5.6

func ExitCode(err error) int

ExitCode is the exported entry point for main(): it returns the process exit code implied by err (see exitCode).

func GenerateSchemaDoc added in v0.8.6

func GenerateSchemaDoc(root *cobra.Command) any

GenerateSchemaDoc exposes schema generation for the cmd/shinyhub conformance tests, which exercise the full tree including server commands. The return type is any so schemaDoc stays unexported; callers consume it via json.Marshal.

func RenderAction added in v0.8.6

func RenderAction(cmd *cobra.Command, status string, fields map[string]any, prose string) error

RenderAction is the exported form for use by cmd/shinyhub/main.go commands that live outside the cli package. It behaves identically to renderAction.

func Report added in v0.8.6

func Report(err error) int

Report is the root error boundary: main() calls os.Exit(cli.Report(err)).

func SetVersion

func SetVersion(v string)

SetVersion updates the version string reported by CLI subcommands. Called by the parent binary's init() so both the server (`shinyhub serve`) and the CLI subcommands report the same version.

Types

type ExitCodeError added in v0.5.6

type ExitCodeError struct {
	Code int
	Err  error
	// Kind is the structured error kind for the envelope. Empty means
	// classify() derives it from Code (legacy fleet paths) or falls back.
	Kind Kind
	// Reported is set when the command already wrote a contextual,
	// user-facing message for this error. The renderer then skips the prose
	// duplication; the structured envelope is still emitted.
	Reported bool
}

ExitCodeError wraps an error with a specific process exit code. main() inspects the returned error chain for this type via errors.As and exits with Code; without it, cobra's default non-nil-error exit (1) applies.

Codes: 0 success/report, 1 usage/manifest/validation, 2 plan-detailed-exitcode changes-pending, 3 transport/auth, 4 partial convergence, 5 conflicts, 6 server not ready. schedule --follow commands propagate the remote job's own exit code (exit_code_passthrough).

func (*ExitCodeError) Error added in v0.5.6

func (e *ExitCodeError) Error() string

func (*ExitCodeError) Unwrap added in v0.5.6

func (e *ExitCodeError) Unwrap() error

type Kind added in v0.8.6

type Kind string

Kind is the stable machine-readable failure category carried in structured error envelopes and listed in the schema document's errors array. Consumers branch on Kind, not on message text.

const (
	KindValidation           Kind = "validation"
	KindNotFound             Kind = "not_found"
	KindConfirmationRequired Kind = "confirmation_required"
	KindAuth                 Kind = "auth"
	KindNetwork              Kind = "network"
	KindTimeout              Kind = "timeout"
	KindRateLimit            Kind = "rate_limit"
	KindServerError          Kind = "server_error"
	KindPartialConvergence   Kind = "partial_convergence"
	KindConflict             Kind = "conflict"
	KindServerNotReady       Kind = "server_not_ready"
	KindJobFailed            Kind = "job_failed"
	KindInternal             Kind = "internal"
)

Jump to

Keyboard shortcuts

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