cli

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAppNotPointer when app-instance not pointer to struct
	ErrAppNotPointer = errors.New("app must be a pointer to a struct")
	// ErrConfigNotPointer when app-instance not pointer to struct
	ErrConfigNotPointer = errors.New("config must be a pointer to a struct")
)

Functions

func Run added in v1.7.1

func Run(opts ...Option) error

Run creates instance of cli.App with Options. Validate options with https://github.com/go-playground/validator Required: - App instance - Logger

Types

type Author added in v1.8.1

type Author = cli.Author

type Command added in v1.8.1

type Command = cli.Command

type Commandor added in v1.8.1

type Commandor func(*Options) Command

type Context added in v1.8.1

type Context = cli.Context

type Flag added in v1.9.1

type Flag = cli.Flag

type Flager added in v1.9.1

type Flager func(*Options) Flag

type Handler added in v1.9.1

type Handler func(*Options) func(*Context) error

type Instance

type Instance interface {
	Run(RunOptions) error
	Shutdown(ctx context.Context) error
}

Instance abstraction layer above Application

type IntFlag added in v1.9.1

type IntFlag = cli.IntFlag

type Option

type Option func(*Options)

Option closure

func App

func App(app Instance) Option

App closure to set field in Options

func BuildTime

func BuildTime(buildTime string) Option

BuildTime closure to set field in Options

func BuildVersion

func BuildVersion(buildVersion string) Option

BuildVersion closure to set field in Options

func Commands added in v1.8.1

func Commands(cmds ...Commandor) Option

Commands closure to set additional commands for CLI

func Config added in v1.7.1

func Config(src, conf interface{}) Option

Config closure to set config source and interface in Options

func Debug added in v1.7.1

func Debug(args ...bool) Option

Debug closure to set debug and quiet state of logger in Options

func Flags added in v1.9.1

func Flags(flags ...Flager) Option

Flags closure to set additional commands for CLI

func Logger

func Logger(log logger.Logger) Option

Logger closure to set field in Options

func MigrationsPath added in v1.8.1

func MigrationsPath(path string) Option

MigrationsPath closure to set param in Options

func Name

func Name(name string) Option

Name closure to set field in Options

func Trigger added in v1.9.1

func Trigger(action, before, after Handler) Option

Trigger closure to set triggers for CLI

func Usage

func Usage(descr string) Option

Usage closure to set field in Options

func Users

func Users(users []cli.Author) Option

Users closure to set field in Options

type Options

type Options struct {
	App             Instance
	Logger          logger.Logger `validate:"required"`
	ConfigSource    interface{}   `validate:"required"`
	ConfigInterface interface{}   `validate:"required"`
	DB              *pg.DB
	Redis           *redis.Client
	Users           []cli.Author
	Debug           bool
	Quiet           bool
	Usage           string
	Name            string
	BuildTime       string
	BuildVersion    string
	// contains filtered or unexported fields
}

Options for creating cli.App instance

type RunOptions added in v1.7.1

type RunOptions struct {
	DB           *pg.DB
	Redis        *redis.Client
	Logger       logger.Logger
	Debug        bool
	BuildTime    string
	BuildVersion string
}

RunOptions for pass db, redis, etc to application:

type StringFlag added in v1.9.1

type StringFlag = cli.StringFlag

Jump to

Keyboard shortcuts

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