cli

package
v0.0.0-...-8226121 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit(code int) error

func RegisterFlags

func RegisterFlags(cmd *cobra.Command, flags ...FlagRegisterer) error

Types

type CommandExitCode

type CommandExitCode struct {
	ExitCode int
}

func (CommandExitCode) Error

func (c CommandExitCode) Error() string

type Flag

type Flag[T any] struct {
	Name        string
	Short       string
	Description string
	Default     T

	Persistent bool

	Check func(in T) error

	Deprecated *string
	Hidden     bool
}

func (Flag[T]) AsInterface

func (f Flag[T]) AsInterface() FlagInterface[T]

func (Flag[T]) Get

func (f Flag[T]) Get(cmd *cobra.Command) (T, error)

func (Flag[T]) GetName

func (f Flag[T]) GetName() string

func (Flag[T]) Register

func (f Flag[T]) Register(cmd *cobra.Command) error

func (Flag[T]) Validate

func (f Flag[T]) Validate(cmd *cobra.Command) error

type FlagInterface

type FlagInterface[T any] interface {
	FlagRegisterer
	Get(cmd *cobra.Command) (T, error)
}

type FlagRegisterer

type FlagRegisterer interface {
	GetName() string

	Register(cmd *cobra.Command) error
	Validate(cmd *cobra.Command) error
}

type RunE

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

func ValidateFlags

func ValidateFlags(flags ...FlagRegisterer) RunE

type Runner

type Runner []RunE

func (Runner) Run

func (r Runner) Run(cmd *cobra.Command, args []string) error

func (Runner) With

func (r Runner) With(calls ...RunE) Runner

Jump to

Keyboard shortcuts

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