cli

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ExitOK          = 0
	ExitFail        = 1
	ExitUsage       = 2
	ExitNoChanges   = 3
	ExitBusy        = 75
	ExitDoctorFail  = 78
	ExitInterrupted = 130
)

Variables

View Source
var (
	// Version is the semantic version (e.g., "1.0.0").
	Version = "dev"
	// Commit is the git commit SHA.
	Commit = "unknown"
	// BuildDate is the build timestamp in RFC3339 format.
	BuildDate = "unknown"
)

Build-time variables set via -ldflags.

Functions

func Execute

func Execute(args []string) int

Execute runs the CLI with the given args and returns a process exit code.

func NewJobLogger

func NewJobLogger(cfg config.LogConfig, logFileFlag string) (zerolog.Logger, func() error, error)

NewJobLogger builds a logger for oneshot maintenance jobs.

It always writes logs to stderr so stdout can be reserved for command output.

func NewLogger

func NewLogger(cfg config.LogConfig, logFileFlag string) (zerolog.Logger, func() error, error)

NewLogger builds a CLI logger from config.

Rules: - log.format=json: structured logs to stdout. - log.format=text: human-friendly logs to stderr. - If --log-file, PFS_LOG_FILE, or log.file is set, structured logs are also duplicated to that file.

Types

type CLIError

type CLIError struct {
	Code     int
	Cmd      string
	Headline string
	Cause    error
	Hint     string
	Silent   bool
}

CLIError represents a user-facing CLI error

func (*CLIError) Error

func (e *CLIError) Error() string

Error implements the error interface.

func (*CLIError) Lines

func (e *CLIError) Lines() []string

Lines returns the formatted error lines (max 3) for printing to stderr.

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

Unwrap enables errors.Is / errors.As.

type OpenLogFileError

type OpenLogFileError struct {
	Path  string
	Cause error
}

OpenLogFileError indicates the optional log file output could not be enabled.

func (*OpenLogFileError) Error

func (e *OpenLogFileError) Error() string

Error formats the error message for users.

func (*OpenLogFileError) Unwrap

func (e *OpenLogFileError) Unwrap() error

Unwrap returns the underlying failure.

Jump to

Keyboard shortcuts

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