Documentation
¶
Overview ¶
Package root provides the reusable root Cobra command constructor that wires configuration loading, logging setup, update checks, and feature-flagged subcommand registration (version, update, init, docs, MCP).
The NewCmdRoot and NewCmdRootWithConfig functions build a root command whose PersistentPreRunE handles config merging (local files + embedded assets), log level/format configuration, and optional self-update prompting before any subcommand executes.
Index ¶
- Variables
- func Execute(rootCmd *cobra.Command, props *p.Props)
- func NewCmdRoot(props *p.Props, subcommands ...*cobra.Command) *cobra.Command
- func NewCmdRootWithConfig(props *p.Props, configPaths []string, subcommands ...*cobra.Command) *cobra.Command
- type ConfigLoadOptions
- type FlagValues
- type OutdatedVersionOption
- type UpdateCheckResult
Constants ¶
This section is empty.
Variables ¶
var ErrUpdateComplete = errors.New("update complete — restart required")
ErrUpdateComplete is returned by PersistentPreRunE when a self-update has completed successfully. The Execute wrapper handles this by exiting cleanly without logging an error.
Functions ¶
func Execute ¶
Execute runs the root command with centralized error handling. It silences Cobra's default error output and routes any error returned by the command tree through ErrorHandler.Check at Fatal level.
func NewCmdRoot ¶
NewCmdRoot creates the root command with Props wiring and optional subcommands.
func NewCmdRootWithConfig ¶
func NewCmdRootWithConfig(props *p.Props, configPaths []string, subcommands ...*cobra.Command) *cobra.Command
NewCmdRootWithConfig creates the root command for the CLI application. It accepts additional configuration file paths to be considered during initialization. NewCmdRoot creates the root command with Props wiring and optional subcommands.
Types ¶
type ConfigLoadOptions ¶
type ConfigLoadOptions struct {
CfgPaths []string
ConfigPaths []string
Props *p.Props
AllowEmpty bool
}
ConfigLoadOptions holds the options needed for loading configuration.
type FlagValues ¶
FlagValues holds the command-line flag values extracted from cobra command.
type OutdatedVersionOption ¶
type OutdatedVersionOption func(*outdatedVersionConfig)
OutdatedVersionOption configures handleOutdatedVersion behavior.
type UpdateCheckResult ¶
UpdateCheckResult holds the result of checking for updates.