Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Name string
Description string
Version string
BuildDate string
BuildCommit string
CmdList ICommands
BeforeCommandRun BeforeCommandRunFunc
}
App is the root application that dispatches CLI arguments to commands.
func (*App) PrintUsage ¶
PrintUsage writes the full application usage to w.
type BeforeCommandRunFunc ¶
BeforeCommandRunFunc is called once before a command's Run, allowing the caller to enrich or validate the context (logging, tracing, etc.).
type Command ¶
type Command[T any] struct { Name string HelpDesc string Exec CommandFunc[T] ContextInit ContextInitFunc }
Command is a generic command with a typed configuration struct T. The configuration is loaded from defaults, environment variables, and CLI flags using the goconfig library, following the struct tags:
- default:"…" — default value
- env:"…" — environment variable name
- envPrefix:"…" — prefix applied to all env tags in nested structs
- cli:"…" — long CLI flag (without "--")
- json:"…" — display name fallback
- field:"…" — display name (highest priority)
func (*Command[T]) PrintHelp ¶
PrintHelp writes full command help including the configuration options table to w.
func (*Command[T]) Run ¶
Run executes the command. It intercepts --help / -h / help before loading config so users can request help even with missing required env vars. Scanning stops at "--" so downstream flags are not misinterpreted.
func (*Command[T]) WithInitContext ¶
func (c *Command[T]) WithInitContext(ctxWrapper ContextInitFunc) *Command[T]
WithInitContext returns a shallow copy of the command with the given context initializer.
type CommandFunc ¶
CommandFunc is the execution function for a typed command.
type ContextInitFunc ¶
ContextInitFunc initializes or enriches the context before command execution.
type HelpProvider ¶
HelpProvider is an optional interface commands can implement to print detailed help that includes the configuration options table.