Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 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, because an empty result 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

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

func UserAgent() string

UserAgent is the name every RESTCONF request sends.

func Version

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

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