cli

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 53 Imported by: 0

Documentation

Overview

Package cli contains the cobra command tree for the compliancekit binary. Each subcommand lives in its own file (version.go, doctor.go, scan.go, ...).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, info BuildInfo) error

Execute builds the cobra command tree and runs whichever subcommand the user invoked. It is the single entry point from main.

Types

type BuildInfo

type BuildInfo struct {
	Version string
	Commit  string
	Date    string
}

BuildInfo carries values injected via -ldflags at build time. It's passed in from main rather than read from package-level vars so the CLI package stays testable in isolation.

type ExitCodeError

type ExitCodeError struct {
	Code    int
	Message string
}

ExitCodeError wraps an error that should produce a specific process exit code in main(). Used for outcomes that are not "the tool failed" but still warrant non-zero exit -- e.g. a scan that ran successfully but produced findings at or above the configured fail-on severity.

main.go checks errors.As(err, *ExitCodeError) and uses Code; cobra just sees a normal error and propagates it up.

func NewExitCode

func NewExitCode(code int, format string, args ...any) *ExitCodeError

NewExitCode returns an ExitCodeError with the given exit code and a formatted message.

func (*ExitCodeError) Error

func (e *ExitCodeError) Error() string

Error implements error.

func (*ExitCodeError) ExitCode

func (e *ExitCodeError) ExitCode() int

ExitCode returns the intended process exit code.

Jump to

Keyboard shortcuts

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