internal

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUsage = errors.New("invalid usage")

ErrInvalidUsage when returned by a Handler the usage message is displayed.

Functions

func Output added in v0.2.0

func Output(v interface{}, format string) error

func OutputLine

func OutputLine(format string) error

OutputLine prints the given string to stdout appending a new-line char.

Types

type CLI

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

CLI is a cli subcommands executor.

func New

func New(desc string, f FlagFunc, cmds []*Command) *CLI

New creates new cli executor.

func (*CLI) Run

func (r *CLI) Run(argv []string) error

Run runs one or the given commands based on argv.

Panics if argv is empty.

If ErrInvalidUsage is returned there's no need to print it, the usage message is already sent to STDERR.

type Command

type Command struct {
	Name      string
	Args      []string
	Desc      string
	Handler   HandlerFunc
	ParseFunc func(*flag.FlagSet)
}

Command is a cli subcommand.

type FlagFunc

type FlagFunc func(fs *flag.FlagSet)

FlagFunc prepares fs for parsing, setting flags.

type HandlerFunc

type HandlerFunc func(args []string) error

HandlerFunc is a subcommand handler, fs is already parsed.

type JSONMapFlag added in v0.2.0

type JSONMapFlag map[string]interface{}

func (*JSONMapFlag) Set added in v0.2.0

func (f *JSONMapFlag) Set(s string) error

func (*JSONMapFlag) String added in v0.2.0

func (f *JSONMapFlag) String() string

type LogLevelFlag added in v0.4.0

type LogLevelFlag logger.Level

func (*LogLevelFlag) Set added in v0.4.0

func (f *LogLevelFlag) Set(s string) error

func (*LogLevelFlag) String added in v0.4.0

func (f *LogLevelFlag) String() string

type StringsMapFlag added in v0.2.0

type StringsMapFlag map[string]string

func (*StringsMapFlag) Set added in v0.2.0

func (f *StringsMapFlag) Set(s string) error

func (*StringsMapFlag) String added in v0.2.0

func (f *StringsMapFlag) String() string

type TimeFlag added in v0.4.0

type TimeFlag time.Time

func (*TimeFlag) Set added in v0.4.0

func (f *TimeFlag) Set(s string) error

func (*TimeFlag) String added in v0.4.0

func (f *TimeFlag) String() string

Jump to

Keyboard shortcuts

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