cli

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package cli wires up the cobra command tree for dbagent.

Index

Constants

View Source
const (
	ExitOK                     = 0
	ExitUsageError             = 1
	ExitNoConfig               = 2
	ExitExtNotReady            = 3
	ExitConnFailed             = 4
	ExitInternal               = 5
	ExitParseFailed            = 6
	ExitFindingsAboveThreshold = 7
)

Exit codes. Each command returns an *ExitError carrying one of these when it wants to override the default cobra exit code of 1.

Variables

View Source
var Version = "dev"

Version is set at build time via -ldflags. The Makefile populates it with `git describe --tags --always --dirty`, producing values like "v0.4.1" for a clean tagged build and "v0.4.1-7-gabcd123-dirty" for in-development work past a tag.

When it is left at its "dev" default (plain `go build`, or `go install …@vX.Y.Z` which ignores ldflags), resolvedVersion() falls back to runtime build info so installs from a pinned tag still show that tag instead of "dev". Builds off main without a tag will continue to show "dev" with a pseudo-version appended.

Functions

func Execute

func Execute() error

Execute builds the root command tree and runs it, returning any error produced by the command (so main.go can inspect ExitError).

func Logger

func Logger(cmd *cobra.Command) *slog.Logger

Logger retrieves the slog.Logger stored on the cobra command's context. Falls back to slog.Default if nothing was set.

Types

type ExitError

type ExitError struct {
	Code int
	Err  error
}

ExitError is a typed error that carries a process exit code, so that main.go can translate a command failure into the right exit status without re-encoding error categories as strings.

func (*ExitError) Error

func (e *ExitError) Error() string

Error implements error by delegating to the wrapped error.

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

Unwrap exposes the wrapped error for errors.Is / errors.As.

Directories

Path Synopsis
Package style centralises dbagent's visual design tokens.
Package style centralises dbagent's visual design tokens.

Jump to

Keyboard shortcuts

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