application

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GetLogLevelFromArgs

func GetLogLevelFromArgs(args []string) slog.Level

func HelpFuncE

func HelpFuncE(cmd *cobra.Command, args []string) error

func RunCatchFuncE

func RunCatchFuncE(cmd *cobra.Command, args []string) error

RunCatchFuncE is an empty catch function to allow overrides through persistentPreRunE

func SubCommandInitializePrintNameFunc

func SubCommandInitializePrintNameFunc(cmd *cobra.Command)

Types

type Application

type Application interface {
	ExecuteContext(ctx context.Context) error
}

func New

func New(c Config) (Application, error)

type Command

type Command struct {
	Command     *cobra.Command
	SubCommands []Commander
	Configure   func(c *cobra.Command)
}

func (Command) Initialize

func (c Command) Initialize(f func(cmd *cobra.Command)) *cobra.Command

type Commander

type Commander interface {
	Initialize(f func(c *cobra.Command)) *cobra.Command
}

type Config

type Config struct {
	Name                     string
	Title                    string
	Banner                   string
	Version                  Version
	EnableGracefulShutdown   bool
	Logger                   *slog.Logger
	OverrideRunE             func(cmd *cobra.Command, args []string) error
	PersistentPreRunE        []func(cmd *cobra.Command, args []string) error // collection of PreRunE functions
	PersistentPostRunE       []func(cmd *cobra.Command, args []string) error // collection of PostRunE functions
	ShutdownSignals          []os.Signal
	ShutdownTimeout          time.Duration
	SubCommands              []Commander
	SubCommandInitializeFunc func(cmd *cobra.Command)
	ValidArgs                []string
}

func (Config) RegisterCommand

func (c Config) RegisterCommand(cmd Commander, f func(*cobra.Command))

func (Config) RegisterCommands

func (c Config) RegisterCommands(cmds []Commander, f func(*cobra.Command))

func (Config) RegisterPersistentPostRunE

func (c Config) RegisterPersistentPostRunE(f func(cmd *cobra.Command, args []string) error)

func (Config) RegisterPersistentPreRunE

func (c Config) RegisterPersistentPreRunE(f func(cmd *cobra.Command, args []string) error)

func (Config) Validate

func (c Config) Validate() error

type Version

type Version struct {
	Full       string
	Branch     string
	Tag        string
	Commit     string
	CommitDate string
	BuildDate  string
	Major      string
	Minor      string
	Patch      string
	PreRelease string
}

func (Version) IsValid added in v0.2.0

func (v Version) IsValid() bool

Jump to

Keyboard shortcuts

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