cli

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Package cli provides the command-line interface for gryph.

Index

Constants

View Source
const (
	SelfAuditActionInstall          = "install"
	SelfAuditActionUninstall        = "uninstall"
	SelfAuditActionConfigChange     = "config_change"
	SelfAuditActionPurge            = "purge"
	SelfAuditActionDatabaseInit     = "database_init"
	SelfAuditActionRetentionCleanup = "retention_cleanup"
	SelfAuditActionHookError        = "hook_error"
	SelfAuditResultSuccess          = "success"
	SelfAuditResultError            = "error"
	SelfAuditResultSkipped          = "skipped"
)

SelfAuditAction constants for self-audit logging.

View Source
const (
	ExitSuccess       = 0 // Success
	ExitGeneral       = 1 // General/unknown error
	ExitConfig        = 2 // Invalid YAML, missing required config fields
	ExitDatabase      = 3 // Database init fails, corrupt/locked
	ExitAgentNotFound = 4 // Agent not found or not detected
	ExitHookFailed    = 5 // Hook installation/removal fails
)

Exit codes per specification (Section 14.4).

Variables

This section is empty.

Functions

func ErrAgentNotFound

func ErrAgentNotFound(agentName string) *cliError

ErrAgentNotFound creates an agent not found error.

func ErrConfig

func ErrConfig(message string, err error) *cliError

ErrConfig creates a configuration error.

func ErrDatabase

func ErrDatabase(message string, err error) *cliError

ErrDatabase creates a database error.

func ErrHookFailed

func ErrHookFailed(message string, err error) *cliError

ErrHookFailed creates a hook operation failure error.

func Execute

func Execute() error

Execute runs the root command.

func NewCLIError

func NewCLIError(code int, message string) *cliError

NewCLIError creates a new CLIError with the given code and message.

func NewCatCmd added in v0.3.5

func NewCatCmd() *cobra.Command

func NewConfigCmd

func NewConfigCmd() *cobra.Command

func NewCostCmd added in v0.4.0

func NewCostCmd() *cobra.Command

NewCostCmd creates the cost command.

func NewDiffCmd

func NewDiffCmd() *cobra.Command

NewDiffCmd creates the diff command.

func NewDoctorCmd

func NewDoctorCmd() *cobra.Command

NewDoctorCmd creates the doctor command.

func NewExportCmd

func NewExportCmd() *cobra.Command

NewExportCmd creates the export command.

func NewHookCmd

func NewHookCmd() *cobra.Command

NewHookCmd creates the internal _hook command.

func NewInstallCmd

func NewInstallCmd() *cobra.Command

NewInstallCmd creates the install command.

func NewLogsCmd

func NewLogsCmd() *cobra.Command

NewLogsCmd creates the logs command.

func NewQueryCmd

func NewQueryCmd() *cobra.Command

NewQueryCmd creates the query command.

func NewRetentionCmd

func NewRetentionCmd() *cobra.Command

NewRetentionCmd creates the retention command.

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd creates the root command.

func NewSelfLogCmd

func NewSelfLogCmd() *cobra.Command

NewSelfLogCmd creates the self-log command.

func NewSessionCmd

func NewSessionCmd() *cobra.Command

NewSessionCmd creates the session command.

func NewSessionsCmd

func NewSessionsCmd() *cobra.Command

NewSessionsCmd creates the sessions command.

func NewStatsCmd added in v0.2.8

func NewStatsCmd() *cobra.Command

func NewStatusCmd

func NewStatusCmd() *cobra.Command

NewStatusCmd creates the status command.

func NewStreamCmd

func NewStreamCmd() *cobra.Command

NewStreamCmd creates the hidden stream parent command.

func NewUninstallCmd

func NewUninstallCmd() *cobra.Command

NewUninstallCmd creates the uninstall command.

func NewVersionCmd

func NewVersionCmd() *cobra.Command

func RegisterCheckFactory added in v0.7.0

func RegisterCheckFactory(f func(cfg *config.Config) security.Check)

RegisterCheckFactory registers a factory that produces a security.Check. Intended for external binaries that import gryph as a library and want to contribute additional security checks without modifying this package.

Call order: typically from init() in a package blank-imported by the external binary's main. Each registered factory is invoked once per NewApp() call, and the returned Check (if non-nil) is added to the evaluator. Factories that return nil are ignored — this lets callers conditionally enable/disable checks based on the provided *config.Config.

This function is not safe for concurrent use. Register factories before any goroutine calls NewApp.

func WrapError

func WrapError(code int, message string, err error) *cliError

WrapError creates a new CLIError wrapping an underlying error.

Types

type App

type App struct {
	Config         *config.Config
	Store          storage.Store
	Registry       *agent.Registry
	Presenter      tui.Presenter
	Paths          *config.Paths
	Security       *security.Evaluator
	PrivacyChecker *events.PrivacyChecker
}

App holds the application dependencies.

func NewApp

func NewApp(cfg *config.Config) (*App, error)

NewApp creates a new App with the given configuration.

func (*App) Close

func (a *App) Close() error

Close closes the application resources.

func (*App) InitStore

func (a *App) InitStore(ctx context.Context) error

InitStore initializes the database store.

type ExitCoder

type ExitCoder interface {
	ExitCode() int
	Message() string
}

ExitCoder is an interface for errors that carry a custom exit code and message.

type GlobalFlags

type GlobalFlags struct {
	ConfigPath string
	Verbose    bool
	Quiet      bool
	NoColor    bool
	Format     string
}

GlobalFlags holds the global command flags.

Jump to

Keyboard shortcuts

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