cli

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 17 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

Author represents someone who has contributed to a cli project.

type Command added in v1.8.1

type Command = cli.Command

Command is a subcommand for a cli.App.

type Commandor added in v1.8.1

type Commandor func(*Options) Command

Commandor closure for applying options to command

type Context added in v1.8.1

type Context = cli.Context

Context is a type that is passed through to each Handler action in a cli application. Context can be used to retrieve context-specific Args and parsed command-line options.

type Flag added in v1.9.1

type Flag = cli.Flag

Flag is a common interface related to parsing flags in cli. For more advanced flag parsing techniques, it is recommended that this interface be implemented.

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

IntFlag is a flag with type int

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(commands ...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 ...Flag) 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 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:

func NewRunOptions added in v1.18.0

func NewRunOptions(opts *Options) (RunOptions, error)

type StringFlag added in v1.9.1

type StringFlag = cli.StringFlag

StringFlag is a flag with type string

Jump to

Keyboard shortcuts

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