cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 22 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 implements the Cobra command tree for iserv-cli, supporting both scriptable non-interactive subcommands and the interactive Bubble Tea TUI.

Index

Constants

View Source
const (
	ExitOK        = 0
	ExitError     = 1
	ExitUsage     = 2
	ExitInterrupt = 130
)

Exit codes following POSIX / Go CLI conventions.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, args []string, deps Dependencies) error

Execute runs the CLI with ctx and returns any execution error without exiting the process.

func ExitCode

func ExitCode(err error) int

ExitCode maps an error returned by Execute to a standard process exit code.

func NewRootCmd

func NewRootCmd(deps Dependencies) *cobra.Command

NewRootCmd constructs a fresh, isolated root *cobra.Command tree.

Types

type Dependencies

type Dependencies struct {
	Stdin         io.Reader
	Stdout        io.Writer
	Stderr        io.Writer
	Connect       client.ConnectFunc
	LoadSaved     func() config.SavedConfig
	SaveSaved     func(config.SavedConfig) error
	RunTUI        func(ctx context.Context, cfg config.AppConfig, saved config.SavedConfig, connect client.ConnectFunc, saveFn func(config.SavedConfig) error) error
	DefaultCfgDir string
}

Dependencies injects external boundaries (I/O, SDK factory, config persistence, TUI runner) into NewRootCmd for clean testing and zero global state.

type HealthProbe

type HealthProbe struct {
	Module    string `json:"module"`
	Status    string `json:"status"`
	LatencyMS int64  `json:"latency_ms"`
	Detail    string `json:"detail"`
}

HealthProbe reports connectivity, item count, and latency for a single IServ module.

type UsageError

type UsageError struct {
	Err error
}

UsageError marks invalid CLI arguments or missing required credentials (exit code 2).

func (*UsageError) Error

func (e *UsageError) Error() string

Error implements the error interface.

func (*UsageError) Unwrap

func (e *UsageError) Unwrap() error

Unwrap returns the underlying usage error.

Jump to

Keyboard shortcuts

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