Documentation
¶
Overview ¶
Package cli holds the command plumbing shared by every patchy binary: the conventional cobra root command and the signal-aware execution wrapper.
Index ¶
- func Execute(root *cobra.Command, log *slog.Logger) int
- func NewControllerRoot(name, short string, opts *Options) *cobra.Command
- func NewRoot(name, short string) *cobra.Command
- type Options
- func (o *Options) Bind(cmd *cobra.Command)
- func (o *Options) Bool(key string) bool
- func (o *Options) Duration(key string) time.Duration
- func (o *Options) Float(key string) float64
- func (o *Options) Int(key string) int
- func (o *Options) Load(cmd *cobra.Command) error
- func (o *Options) String(key string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
Execute runs root under a context cancelled by SIGINT/SIGTERM and returns the process exit code; main is the only place allowed to call os.Exit.
func NewControllerRoot ¶
NewControllerRoot builds a controller's root command with the shared options bound and flag/env resolution wired into PersistentPreRunE.
Types ¶
type Options ¶
type Options struct {
// Log is the process logger; main constructs it, telemetry may replace
// it with a fanout after Init.
Log *slog.Logger
// LogLevel is set from --log-level before any command runs.
LogLevel *slog.LevelVar
// ListenAddr is the webhook/health HTTP listen address.
ListenAddr string
// LogLevelName is the configured level: debug, info, warn, or error.
LogLevelName string
// contains filtered or unexported fields
}
Options carries the configuration shared by every controller binary. Precedence: explicit flag > PATCHY_* environment > default.
func NewOptions ¶
func NewOptions() *Options
NewOptions builds Options with the conventional stderr logger and shared verbosity level every binary starts from.
func (*Options) Bind ¶
Bind registers the shared persistent flags on cmd and wires the viper environment binding. Call once from each binary's root command setup. Controller-specific flags are declared on the command itself; Load binds them and the String, Duration, Float and Int accessors read them.