cli

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cli wires the command tree, owns the process exit code, and is the only place that decides what reaches stdout and what reaches stderr.

Index

Constants

View Source
const (
	ExitOK      = 0
	ExitFailure = 1
	ExitUsage   = 2
	ExitPartial = 3
	ExitSignal  = 130
)

Exit codes. A run that reached every controller and rendered its rows exits 0 even when there were no rows: an empty fleet is a normal answer.

Variables

View Source
var ErrUsage = errors.New("invalid usage")

ErrUsage marks a fault in what the operator asked for: a flag that does not parse, an unknown command, a rejected value, or a configuration file that cannot be read. Everything wrapping it exits 2.

Functions

func Run

func Run(args []string) int

Run executes the CLI and returns the process exit code, and owns the signal context because main exits through os.Exit.

func RunWith added in v0.2.0

func RunWith(args []string, st Streams) int

RunWith is Run against caller-supplied streams, which is how the tests drive the real command tree.

func UserAgent added in v0.2.0

func UserAgent() string

UserAgent is what every RESTCONF request identifies itself as.

func Version added in v0.2.0

func Version() string

Version reports the build's version, which is also the suffix UserAgent carries so a controller's own logs identify the client.

Types

type Streams added in v0.2.0

type Streams struct {
	Out    io.Writer
	Err    io.Writer
	In     io.Reader
	InPipe bool
}

Streams is injected rather than read from os so a test can drive the whole tree, the piped-stdin branch of generate-token included.

Jump to

Keyboard shortcuts

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