internal

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 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

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

type JSONMapFlag map[string]interface{}

func (*JSONMapFlag) Set

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

func (*JSONMapFlag) String

func (f *JSONMapFlag) String() string

type LogLevelFlag

type LogLevelFlag logger.Level

func (*LogLevelFlag) Set

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

func (*LogLevelFlag) String

func (f *LogLevelFlag) String() string

type StringsMapFlag

type StringsMapFlag map[string]string

func (*StringsMapFlag) Set

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

func (*StringsMapFlag) String

func (f *StringsMapFlag) String() string

type TimeFlag

type TimeFlag time.Time

func (*TimeFlag) Set

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

func (*TimeFlag) String

func (f *TimeFlag) String() string

Jump to

Keyboard shortcuts

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