climgr

package
v1.0.0-...-4f7f1ef Latest Latest
Warning

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

Go to latest
Published: May 31, 2016 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorModuleRegisted1 = errutil.NewFactory("Module already registed: %q")
	ErrorModuleNotFound1 = errutil.NewFactory("Module not found: %q")
)

errors

View Source
var (
	ErrorCommandRegisted1 = errutil.NewFactory("Command already registed: %q")
)

errors

View Source
var (
	ErrorFlagRegisted1 = errutil.NewFactory("Flag already registed: %q")
)

errors

Functions

func WrapAction

func WrapAction(action func(context *cli.Context) error) func(context *cli.Context)

WrapAction wrap action, handle return error with errutil.Trace()

func WrapActionLogger

func WrapActionLogger(action func(context *cli.Context) error, logger logutil.StdLogger) func(context *cli.Context)

WrapActionLogger wrap action, handle return error with logger

Types

type BoolFunc

type BoolFunc func() bool

BoolFunc return bool, used for callback function

type Manager

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

Manager manage all registed cli module

func NewManager

func NewManager() *Manager

NewManager create a new manager instance

func (*Manager) AddCommand

func (t *Manager) AddCommand(command cli.Command) (err error)

AddCommand add command to manager

func (*Manager) AddModule

func (t *Manager) AddModule(module Module) (err error)

AddModule add module to manager

func (*Manager) DeleteCommand

func (t *Manager) DeleteCommand(command cli.Command)

DeleteCommand delete command from manager

func (*Manager) DeleteModule

func (t *Manager) DeleteModule(module Module)

DeleteModule delete module from manager

func (*Manager) GetCommands

func (t *Manager) GetCommands() (results []cli.Command)

GetCommands return registed commands

func (*Manager) GetFlags

func (t *Manager) GetFlags() (results []cli.Flag)

GetFlags return registed flags

func (*Manager) GetModules

func (t *Manager) GetModules() (results Modules)

GetModules return registed modules, sorted by priority, module name

func (*Manager) MustAddBoolFlag

func (t *Manager) MustAddBoolFlag(flag cli.BoolFlag) cli.BoolFlag

MustAddBoolFlag add bool flag to manager, panic if error

func (*Manager) MustAddIntFlag

func (t *Manager) MustAddIntFlag(flag cli.IntFlag) cli.IntFlag

MustAddIntFlag add int flag to manager, panic if error

func (*Manager) MustAddIntSliceFlag

func (t *Manager) MustAddIntSliceFlag(flag cli.IntSliceFlag) cli.IntSliceFlag

MustAddIntSliceFlag add int slice flag to manager, panic if error

func (*Manager) MustAddStringFlag

func (t *Manager) MustAddStringFlag(flag cli.StringFlag) cli.StringFlag

MustAddStringFlag add string flag to manager, panic if error

func (*Manager) MustAddStringSliceFlag

func (t *Manager) MustAddStringSliceFlag(flag cli.StringSliceFlag) cli.StringSliceFlag

MustAddStringSliceFlag add string slice flag to manager, panic if error

func (*Manager) Reset

func (t *Manager) Reset()

Reset clean all registed modules, commands, flags

func (*Manager) SelectModules

func (t *Manager) SelectModules(moduleNames ...string) (results Modules, err error)

SelectModules return selected modules, sorted by priority, module name

type Module

type Module struct {
	Name         string
	ModuleFunc   ModuleFunc
	CloseFunc    ModuleFunc
	OptionalFunc BoolFunc
	Priority     int8 // smaller value means high priority
}

Module contain module detail

func (Module) Optional

func (t Module) Optional() bool

Optional return module OptionalFunc callback result if exist

type ModuleFunc

type ModuleFunc func(c *cli.Context) (err error)

ModuleFunc module function for execute

type Modules

type Modules []Module

Modules slice of Module

func (Modules) Len

func (t Modules) Len() int

Len return length of slice

func (Modules) Swap

func (t Modules) Swap(i, j int)

Swap change slice 2 element position

Jump to

Keyboard shortcuts

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