snake

package module
v0.16.2-reserved Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 13 Imported by: 23

README

snake

a simple wrapper around cobra

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMethodSignature = errors.New("invalid method signatured")
)
View Source
var (
	ErrMissingResolver = errors.New("missing resolver")
)

Functions

func DecorateTemplate added in v0.10.4

func DecorateTemplate(ctx context.Context, root *cobra.Command, cfg *DecorateOptions) (string, error)

Init patches Cobra's usage template with configuration provided.

func FlagsFor added in v0.13.0

func FlagsFor(str string, m FMap[Method]) (*pflag.FlagSet, error)

func FormatCommandError added in v0.15.1

func FormatCommandError(cmd *cobra.Command, err error) string

func HandleErrorByPrintingToConsole added in v0.8.1

func HandleErrorByPrintingToConsole(cmd *cobra.Command, err error) error

func IsHandledByPrintingToConsole added in v0.8.1

func IsHandledByPrintingToConsole(err error) bool

func NewSnake added in v0.13.0

func NewSnake(opts *NewSnakeOpts) (*cobra.Command, error)

func NewWrappedEnum added in v0.12.0

func NewWrappedEnum[I ~string](values ...I) *wrappedEnum[I]

Types

type Cobrad added in v0.12.1

type Cobrad interface {
	Cobra() *cobra.Command
}

type DecorateOptions added in v0.4.0

type DecorateOptions struct {
	Headings        *color.Color
	Commands        *color.Color
	CmdShortDescr   *color.Color
	ExecName        *color.Color
	Flags           *color.Color
	FlagsDataType   *color.Color
	FlagsDescr      *color.Color
	Aliases         *color.Color
	Example         *color.Color
	NoExtraNewlines bool
	NoBottomNewline bool
}

type ErrHandledByPrintingToConsole added in v0.8.1

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

func (*ErrHandledByPrintingToConsole) Error added in v0.8.1

func (*ErrHandledByPrintingToConsole) Unwrap added in v0.8.1

type FMap added in v0.12.0

type FMap[G any] func(string) G

type Flagged added in v0.12.0

type Flagged interface {
	Flags(*pflag.FlagSet)
}

func NewArgInlineFunc added in v0.12.3

func NewArgInlineFunc[I any](flagFunc func(*pflag.FlagSet), runFunc func() (I, error)) Flagged

type HasRunArgs added in v0.12.0

type HasRunArgs interface{ RunArgs() []reflect.Type }

type IsRunnable added in v0.12.0

type IsRunnable interface {
	HasRunArgs
	Run() reflect.Value
	HandleResponse([]reflect.Value) (*reflect.Value, error)
}

type Method added in v0.12.0

type Method interface {
	Flags(*pflag.FlagSet)
	Run() reflect.Value
	RunArgs() []reflect.Type
	ReturnArgs() []reflect.Type
	ValidateResponse() error
	HandleResponse([]reflect.Value) (*reflect.Value, error)
	Name() string
	Command() Cobrad
	IsContextResolver() bool
}

func NewArgumentMethod added in v0.13.0

func NewArgumentMethod[I any](m Flagged) Method

func NewCommandMethod added in v0.13.0

func NewCommandMethod[I Cobrad](cbra I) Method

type NewSnakeOpts added in v0.13.0

type NewSnakeOpts struct {
	Root                       *cobra.Command
	Commands                   []Method
	Resolvers                  []Method
	GlobalContextResolverFlags bool
}

type Snake added in v0.13.0

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

func (*Snake) Run added in v0.13.0

func (me *Snake) Run(str Method) error

func (*Snake) RunString added in v0.13.0

func (me *Snake) RunString(str string) error

Directories

Path Synopsis
example
wails module

Jump to

Keyboard shortcuts

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