cli

package module
v0.0.0-...-eabe7c8 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCommand = ""
)

Variables

View Source
var (
	// UsageColor is the color in which the
	// command usage will be printed on the screen.
	UsageColor = color.New(color.FgHiCyan)

	// DescriptionColor is the color in which the
	// command usage description will be printed on the screen.
	DescriptionColor = color.New(color.FgCyan)
)

Functions

func CompleteStringArgsDispatcher

func CompleteStringArgsDispatcher(disp *StringArgsDispatcher)

func CompleteSuperStringArgsDispatcher

func CompleteSuperStringArgsDispatcher(disp *SuperStringArgsDispatcher)

func IsErrCommandNotFound

func IsErrCommandNotFound(err error) bool

IsErrCommandNotFound returns true if the passed error can be unwrapped to either ErrCommandNotFound or ErrSuperCommandNotFound.

Types

type ErrCommandNotFound

type ErrCommandNotFound string

func (ErrCommandNotFound) Error

func (e ErrCommandNotFound) Error() string

type ErrSuperCommandNotFound

type ErrSuperCommandNotFound string

func (ErrSuperCommandNotFound) Error

func (e ErrSuperCommandNotFound) Error() string

type StringArgsCommandLogger

type StringArgsCommandLogger interface {
	LogStringArgsCommand(command string, args []string)
}

type StringArgsCommandLoggerFunc

type StringArgsCommandLoggerFunc func(command string, args []string)

func (StringArgsCommandLoggerFunc) LogStringArgsCommand

func (f StringArgsCommandLoggerFunc) LogStringArgsCommand(command string, args []string)

type StringArgsDispatcher

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

func NewStringArgsDispatcher

func NewStringArgsDispatcher(loggers ...StringArgsCommandLogger) *StringArgsDispatcher

func (*StringArgsDispatcher) AddCommand

func (disp *StringArgsDispatcher) AddCommand(command, description string, commandFunc function.Wrapper, resultsHandlers ...function.ResultsHandler) error

func (*StringArgsDispatcher) AddDefaultCommand

func (disp *StringArgsDispatcher) AddDefaultCommand(description string, commandFunc function.Wrapper, resultsHandlers ...function.ResultsHandler) error

func (*StringArgsDispatcher) Commands

func (disp *StringArgsDispatcher) Commands() []string

func (*StringArgsDispatcher) Dispatch

func (disp *StringArgsDispatcher) Dispatch(ctx context.Context, command string, args ...string) error

func (*StringArgsDispatcher) DispatchCombinedCommandAndArgs

func (disp *StringArgsDispatcher) DispatchCombinedCommandAndArgs(ctx context.Context, commandAndArgs []string) (command string, err error)

func (*StringArgsDispatcher) DispatchDefaultCommand

func (disp *StringArgsDispatcher) DispatchDefaultCommand() error

func (*StringArgsDispatcher) HasCommnd

func (disp *StringArgsDispatcher) HasCommnd(command string) bool

func (*StringArgsDispatcher) HasDefaultCommnd

func (disp *StringArgsDispatcher) HasDefaultCommnd() bool

func (*StringArgsDispatcher) MustAddCommand

func (disp *StringArgsDispatcher) MustAddCommand(command, description string, commandFunc function.Wrapper, resultsHandlers ...function.ResultsHandler)

func (*StringArgsDispatcher) MustAddDefaultCommand

func (disp *StringArgsDispatcher) MustAddDefaultCommand(description string, commandFunc function.Wrapper, resultsHandlers ...function.ResultsHandler)

func (*StringArgsDispatcher) MustDispatch

func (disp *StringArgsDispatcher) MustDispatch(ctx context.Context, command string, args ...string)

func (*StringArgsDispatcher) MustDispatchCombinedCommandAndArgs

func (disp *StringArgsDispatcher) MustDispatchCombinedCommandAndArgs(ctx context.Context, commandAndArgs []string) (command string)

func (*StringArgsDispatcher) MustDispatchDefaultCommand

func (disp *StringArgsDispatcher) MustDispatchDefaultCommand()

func (*StringArgsDispatcher) PrintCommands

func (disp *StringArgsDispatcher) PrintCommands(appName string)

func (*StringArgsDispatcher) PrintCommandsUsageIntro

func (disp *StringArgsDispatcher) PrintCommandsUsageIntro(appName string, output io.Writer)

type SuperStringArgsDispatcher

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

func NewSuperStringArgsDispatcher

func NewSuperStringArgsDispatcher(loggers ...StringArgsCommandLogger) *SuperStringArgsDispatcher

func (*SuperStringArgsDispatcher) AddDefaultCommand

func (disp *SuperStringArgsDispatcher) AddDefaultCommand(description string, commandFunc function.Wrapper, resultsHandlers ...function.ResultsHandler) error

func (*SuperStringArgsDispatcher) AddSuperCommand

func (disp *SuperStringArgsDispatcher) AddSuperCommand(superCommand string) (subDisp *StringArgsDispatcher, err error)

func (*SuperStringArgsDispatcher) Commands

func (disp *SuperStringArgsDispatcher) Commands() []string

func (*SuperStringArgsDispatcher) Dispatch

func (disp *SuperStringArgsDispatcher) Dispatch(ctx context.Context, superCommand, command string, args ...string) error

func (*SuperStringArgsDispatcher) DispatchCombinedCommandAndArgs

func (disp *SuperStringArgsDispatcher) DispatchCombinedCommandAndArgs(ctx context.Context, commandAndArgs []string) (superCommand, command string, err error)

func (*SuperStringArgsDispatcher) DispatchDefaultCommand

func (disp *SuperStringArgsDispatcher) DispatchDefaultCommand() error

func (*SuperStringArgsDispatcher) HasCommnd

func (disp *SuperStringArgsDispatcher) HasCommnd(superCommand string) bool

func (*SuperStringArgsDispatcher) HasSubCommnd

func (disp *SuperStringArgsDispatcher) HasSubCommnd(superCommand, command string) bool

func (*SuperStringArgsDispatcher) MustAddDefaultCommand

func (disp *SuperStringArgsDispatcher) MustAddDefaultCommand(description string, commandFunc function.Wrapper, resultsHandlers ...function.ResultsHandler)

func (*SuperStringArgsDispatcher) MustAddSuperCommand

func (disp *SuperStringArgsDispatcher) MustAddSuperCommand(superCommand string) (subDisp *StringArgsDispatcher)

func (*SuperStringArgsDispatcher) MustDispatch

func (disp *SuperStringArgsDispatcher) MustDispatch(ctx context.Context, superCommand, command string, args ...string)

func (*SuperStringArgsDispatcher) MustDispatchCombinedCommandAndArgs

func (disp *SuperStringArgsDispatcher) MustDispatchCombinedCommandAndArgs(ctx context.Context, commandAndArgs []string) (superCommand, command string)

func (*SuperStringArgsDispatcher) MustDispatchDefaultCommand

func (disp *SuperStringArgsDispatcher) MustDispatchDefaultCommand()

func (*SuperStringArgsDispatcher) PrintCommands

func (disp *SuperStringArgsDispatcher) PrintCommands(appName string)

func (*SuperStringArgsDispatcher) PrintCommandsUsageIntro

func (disp *SuperStringArgsDispatcher) PrintCommandsUsageIntro(appName string, output io.Writer)

func (*SuperStringArgsDispatcher) SubCommands

func (disp *SuperStringArgsDispatcher) SubCommands(superCommand string) []string

Jump to

Keyboard shortcuts

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