cli

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package cli assembles the kernel, the contracts and the extensions into one program. It is the only package that knows about all of them: spec knows nothing of cobra, and transport nothing of the command tree.

Index

Constants

View Source
const (
	ExitOK = 0

	// ExitError is anything not classified below.
	ExitError = 1

	// ExitUsage is a malformed command line: unknown flag, wrong arity.
	ExitUsage = 2

	// ExitAuth means no usable credentials. Retrying without logging in again
	// cannot help.
	ExitAuth = 3

	// ExitPermission means the identity is fine but not allowed.
	ExitPermission = 4

	ExitNotFound = 5

	// ExitValidation is a local failure: the request was never sent.
	ExitValidation = 6

	// ExitAPI is a service-side refusal that is none of the above.
	ExitAPI = 7

	// ExitInterrupted follows the shell convention of 128 + SIGINT.
	ExitInterrupted = 130
)

Exit codes are part of the CLI's contract, because this tool is meant to be wrapped by other programs. A caller has to be able to tell "log in again" from "you cannot do that" from "the service is down" without parsing prose.

Variables

This section is empty.

Functions

func Execute

func Execute(args []string) int

Types

type App

type App struct {
	Out io.Writer
	Err io.Writer
	In  io.Reader
	// contains filtered or unexported fields
}

App is one run's state. Keeping it in a struct rather than package variables lets tests build several that do not leak flags into each other.

func (*App) Root

func (a *App) Root() (*cobra.Command, error)

func (*App) Run

func (a *App) Run(args []string) int

type Failure

type Failure struct {
	// Kind is the coarse category, matching the exit code.
	Kind string `json:"kind"`

	// Code is the service's own error code (NOT_A_MEMBER, TOKEN_EXPIRED) when
	// there is one. This is contract; Message is not.
	Code string `json:"code,omitempty"`

	Status int `json:"status,omitempty"`

	Message string `json:"message"`

	// Problems carries every validation failure, since they are reported
	// together rather than one per run.
	Problems []string `json:"problems,omitempty"`

	// Hint is the next action, when there is an obvious one.
	Hint string `json:"hint,omitempty"`

	ExitCode int `json:"exit_code"`
}

Failure is the machine-readable form of an error, emitted under -o json and -o yaml so a wrapping program gets a parseable object instead of a sentence.

Jump to

Keyboard shortcuts

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