cli

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func New

func New(ctx stdContext.Context, name string, usage string) *App

func (*App) AddAfterFunc

func (a *App) AddAfterFunc(f Hook)

func (*App) AddBeforeFunc

func (a *App) AddBeforeFunc(f Hook)

func (*App) AddGlobalFlagsFromStruct

func (a *App) AddGlobalFlagsFromStruct(source interface{})

func (*App) RegisterCategory

func (a *App) RegisterCategory(category Category)

func (*App) RegisterCommand

func (a *App) RegisterCommand(command Command)

func (*App) Run

func (a *App) Run(args []string) error

type Category

type Category struct {
	Config

	SubCategories []Category
	SubCommands   []Command
}

type Command

type Command struct {
	Config

	Handler Handler
}

type Config

type Config = cli.Command

type Context

type Context struct {
	Ctx stdContext.Context
	Cli *cli.Context
	// contains filtered or unexported fields
}

func (*Context) Config

func (c *Context) Config() config.Global

func (*Context) Logger

func (c *Context) Logger() logging.Logger

func (*Context) SetConfig

func (c *Context) SetConfig(cfg config.Global)

func (*Context) SetLogger

func (c *Context) SetLogger(logger logging.Logger)

type Handler

type Handler interface {
	Execute(context *Context) error
}

type Hook

type Hook func(ctx *Context) error

func NewNopHook

func NewNopHook() Hook

type Hooks

type Hooks []Hook

func (Hooks) Execute

func (h Hooks) Execute(cliCtx *Context) error

type MockHandler

type MockHandler struct {
	mock.Mock
}

MockHandler is an autogenerated mock type for the Handler type

func NewMockHandler added in v0.3.0

func NewMockHandler(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHandler

NewMockHandler creates a new instance of MockHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHandler) Execute

func (_m *MockHandler) Execute(context *Context) error

Execute provides a mock function with given fields: context

type MockHook added in v0.3.0

type MockHook struct {
	mock.Mock
}

MockHook is an autogenerated mock type for the Hook type

func NewMockHook added in v0.3.0

func NewMockHook(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHook

NewMockHook creates a new instance of MockHook. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHook) Execute added in v0.3.0

func (_m *MockHook) Execute(ctx *Context) error

Execute provides a mock function with given fields: ctx

Jump to

Keyboard shortcuts

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