cli

package
v0.0.0-...-a02776c Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 1 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 holds tiny shared CLI utilities. Today it has one type: ExitError, which carries a custom exit code that the top-level main() catches to call os.Exit explicitly.

Why this exists: Cobra's RunE returning an error always exits 1 (or whatever cobra picks). The verify subcommand needs CI-script-friendly distinction between "finding still present" (exit 1, the build should fail) and "verify couldn't tell" (exit 2, the build should not fail on ambiguous results — the operator needs to investigate). Sprint 03 introduced the convention.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitWithCode

func ExitWithCode(code int, msg string) error

ExitWithCode returns an *ExitError suitable for returning from a Cobra RunE closure. Pair with main()'s `errors.As(err, *cli.ExitError)` catch to translate to a specific os.Exit code.

Types

type ExitError

type ExitError struct {
	Code    int
	Message string
}

ExitError carries an explicit exit code from a Cobra RunE up to main(). It satisfies the error interface so RunE can return it without changing signatures, but main() inspects the type and honours Code via os.Exit.

func (*ExitError) Error

func (e *ExitError) Error() string

Error returns the user-facing message, or a generic "exit N" if no message was supplied.

Jump to

Keyboard shortcuts

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