cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli gives a host program ota's commands as subcommands of its own binary, so updating never needs a second program:

switch os.Args[1] {
case "update", "run", "offer":
	os.Exit(cli.Commands(config)[os.Args[1]](os.Args[2:]))
}

Index

Constants

View Source
const (
	ExitOK            = 0
	ExitError         = 1
	ExitDeferred      = 10
	ExitDrainTimeout  = 11
	ExitRefused       = 20
	ExitDownload      = 30
	ExitRolledBack    = 40
	ExitLocked        = 50
	ExitRestartNeeded = 60
)

Exit codes. Stable, so schedulers and scripts can branch on them.

Variables

This section is empty.

Functions

func Commands

func Commands(cfg func() (Config, error)) map[string]func(args []string) int

Commands returns the subcommands, keyed by name. Each returns an exit code.

func ExitCode

func ExitCode(err error) int

ExitCode maps an ota error to its exit code.

Types

type Config

type Config struct {
	// Client configures the updater for this program. Restarter is ignored by
	// `update`, which always hands off (see restart.HandOff).
	Client client.Options
	// Service, if set, is the service `update` restarts when no launcher runs.
	Service *service.Spec
	// Launcher tunes `run`. Binary, StateDir and Version come from Client.
	Launcher restart.LauncherOptions
}

Config is what the host supplies. It is a function so the host loads its configuration only when a command actually runs.

Jump to

Keyboard shortcuts

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