factory

package
v0.1.0-alpha.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandConfig

type CommandConfig struct {
	Use     string
	Short   string
	Long    string
	Example string
	Run     RunFunc
}

CommandConfig represents the configuration for creating a command

type CommandFactory

type CommandFactory struct {
	// contains filtered or unexported fields
}

CommandFactory handles the creation and configuration of cobra commands

func NewCommandFactory

func NewCommandFactory(logger *observability.Logger) *CommandFactory

NewCommandFactory creates a new command factory

func (*CommandFactory) AddMiddleware

func (f *CommandFactory) AddMiddleware(middleware CommandMiddleware)

AddMiddleware adds a middleware to the factory

func (*CommandFactory) CreateCommand

func (f *CommandFactory) CreateCommand(cfg *CommandConfig) *cobra.Command

CreateCommand creates a new cobra command with the given configuration

type CommandMiddleware

type CommandMiddleware func(next RunFunc) RunFunc

CommandMiddleware represents a function that wraps a command's execution

func ErrorHandlingMiddleware

func ErrorHandlingMiddleware() CommandMiddleware

ErrorHandlingMiddleware adds structured error handling

func LoggingMiddleware

func LoggingMiddleware(logger *observability.Logger) CommandMiddleware

LoggingMiddleware adds logging to command execution

func RecoveryMiddleware

func RecoveryMiddleware(logger *observability.Logger) CommandMiddleware

RecoveryMiddleware adds panic recovery

type RunFunc

type RunFunc func(ctx context.Context, cmd *cobra.Command, args []string) error

RunFunc represents a command's execution function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL