Documentation
¶
Overview ¶
Package app wraps cobra so terminull apps never touch it directly.
An App owns the root command, five global flags, and the boot order: debug switch, output validation, renderer selection, config load. Handlers receive a *Context (config, logger, IO, typed flag getters) instead of cobra types. Only two intentional leaks exist: Flags takes a *pflag.FlagSet and Args is a cobra.PositionalArgs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App owns the root cobra command. Build one per process with New, register commands with Add, run with Execute.
func New ¶
New builds an App with the five global flags:
--config/-f, --output/-o table|json|yaml, --no-color, --verbose, --debug
func (*App) Execute ¶
Execute runs args against a signal-scoped ctx (see core.SignalContext). Parse and setup failures return ExitCodeError(2); handler errors pass through for core.ExitCodeOf mapping by main.
func (*App) Raw ¶
Raw escapes to the underlying cobra command for advanced use. Prefer Add/Execute; Raw exists so the wrapper never blocks you.
type Command ¶
type Command struct {
// Use is the one-line usage, e.g. "deploy --env prod".
Use string
// Short is the short help shown in command lists.
Short string
// Long is the full help text.
Long string
// Args validates positional args (e.g. cobra.MaximumNArgs(1)).
Args cobra.PositionalArgs
// Flags registers command-local flags. Read them back with
// Context.String/Bool/Int/StringSlice.
Flags func(*pflag.FlagSet)
// Children builds a command group; they share the parent's flags.
Children []Command
// Run executes the command. Nil on a group parent prints help.
Run func(*Context) error
}
Command describes one CLI command. Children build groups like `worker {run|pause}`; a parent without Run prints its help.
type Context ¶
type Context struct {
context.Context
Config *config.Config
Logger *render.Logger
Out io.Writer
Err io.Writer
In io.Reader
// Output is the validated --output value: table, json, or yaml.
Output string
// NoColor mirrors --no-color.
NoColor bool
// Verbose mirrors --verbose or --debug.
Verbose bool
// contains filtered or unexported fields
}
Context is what Run handlers receive: cancellation, layered config, a scoped-capable logger, IO, and typed flag access.