cli

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package cli implements the stacktower command-line interface.

Index

Constants

View Source
const (
	LogDebug = log.DebugLevel
	LogInfo  = log.InfoLevel
)

Log levels exported for use in main.go.

View Source
const (
	// ExitCodeFailure is a generic runtime failure.
	ExitCodeFailure = 1
	// ExitCodeUsage indicates invalid input/usage from the caller.
	ExitCodeUsage = 2
	// ExitCodeVuln signals that new vulnerabilities were detected (used by diff --fail-on-vuln).
	ExitCodeVuln = 3
	// ExitCodeInterrupted follows shell convention for SIGINT/SIGTERM.
	ExitCodeInterrupted = 130
)

Variables

This section is empty.

Functions

func ExitCodeForError

func ExitCodeForError(err error) int

ExitCodeForError maps errors to stable process exit codes.

func NewSystemError

func NewSystemError(message string, hint string) error

NewSystemError constructs an execution/network/runtime error with optional hint.

func NewUserError

func NewUserError(message string, hint string) error

NewUserError constructs a usage/input error with an optional actionable hint.

func WrapSystemError

func WrapSystemError(cause error, message string, hint string) error

WrapSystemError wraps a cause as an execution/network/runtime error.

func WrapUserError

func WrapUserError(cause error, message string, hint string) error

WrapUserError wraps a cause as a usage/input error.

Types

type CLI

type CLI struct {
	Logger *log.Logger
	Quiet  bool // suppress non-essential output (success messages, stats, next steps)
}

CLI holds shared state for all commands.

func New

func New(w io.Writer, level log.Level) *CLI

New creates a new CLI instance with a default logger. Registers observability hooks for pipeline and security events.

func (*CLI) RootCommand

func (c *CLI) RootCommand() *cobra.Command

RootCommand creates the root cobra command with all subcommands registered.

func (*CLI) SetLogLevel

func (c *CLI) SetLogLevel(level log.Level)

SetLogLevel updates the logger's level.

func (*CLI) SetQuiet

func (c *CLI) SetQuiet(q bool)

SetQuiet suppresses non-essential CLI output (success messages, stats, hints).

type CLIError

type CLIError struct {
	Kind    ErrorKind
	Message string
	Hint    string
	Cause   error
}

CLIError is a structured CLI-facing error.

func (*CLIError) Error

func (e *CLIError) Error() string

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

type ErrorKind

type ErrorKind string

ErrorKind classifies CLI failures for exit-code mapping.

const (
	ErrorKindUser   ErrorKind = "user"
	ErrorKindSystem ErrorKind = "system"
)

type VulnError added in v1.5.0

type VulnError struct {
	Count int
}

VulnError is returned when --fail-on-vuln detects new vulnerabilities. It maps to ExitCodeVuln (3) via ExitCodeForError.

func (*VulnError) Error added in v1.5.0

func (e *VulnError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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