Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunCommand ¶
Types ¶
type Runner ¶
type Runner interface {
// FlagSets returns flag sets specific to this subcommand.
// They are registered as regular Flags (not PersistentFlags).
FlagSets() []*pflag.FlagSet
// PostRegistration is called after all flags are registered on the cobra command.
PostRegistration(cmd *cobra.Command)
// SetHelpUsage sets custom help and usage functions on the command.
SetHelpUsage(cmd *cobra.Command, shared *SharedFlagSets)
// NewServiceConfig creates the service configuration from parsed flags.
NewServiceConfig(ctx context.Context, shared *SharedFlags) (ServiceConfig, error)
// RunService creates and runs the domain service.
RunService(ctx context.Context, cfg ServiceConfig, logger *slog.Logger) error
}
Runner defines the contract each subcommand must implement.
type ServiceConfig ¶
ServiceConfig must be implemented by every subcommand's config type so the builder can extract App settings for logger initialization.
type SharedFlagSets ¶
type SharedFlagSets struct {
}
SharedFlagSets holds pflag.FlagSet objects created from SharedFlags. Subcommands use these to build their custom help functions.
func NewSharedFlagSets ¶
func NewSharedFlagSets(shared *SharedFlags) SharedFlagSets
type SharedFlags ¶
type SharedFlags struct {
}
SharedFlags holds all flag objects shared across subcommands.
func BuildCommand ¶
func BuildCommand( name, short, long string, flagsRoot *flags.Root, appVersion, commitHash, buildTime string, op flags.Operation, runner Runner, ) (*cobra.Command, *SharedFlags)
BuildCommand constructs a cobra.Command with shared flag registration and a standard run lifecycle: version check -> logger init -> service execution.
Click to show internal directories.
Click to hide internal directories.