command

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HistoryFile string
	MaxLines    = 65536
	Prompt      = ">> "
)

Functions

This section is empty.

Types

type Command

type Command interface {
	Alias() []string
	Help() string
	Execute(ctx *Context, args []string) error
	Check(ctx *Context, args []string) error
}

type Commands

type Commands interface {
	Execute(ctx *Context, cmd string) error
}

type Context

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

func NewContext

func NewContext() *Context

func (*Context) Close

func (ctx *Context) Close() error

func (*Context) Command added in v0.1.1

func (ctx *Context) Command() string

func (*Context) Do

func (ctx *Context) Do(c Commands)

func (*Context) Err

func (ctx *Context) Err() error

func (*Context) Fatalf

func (ctx *Context) Fatalf(format string, args ...interface{})

func (*Context) Next

func (ctx *Context) Next() bool

func (*Context) Output

func (ctx *Context) Output() io.Writer

func (*Context) Printf

func (ctx *Context) Printf(format string, args ...interface{})

func (*Context) ReadHistory

func (ctx *Context) ReadHistory() (int, error)

func (*Context) ReadLine

func (ctx *Context) ReadLine(prompt string) (string, error)

func (*Context) SetHistory

func (ctx *Context) SetHistory(f string)

func (*Context) SetOutput

func (ctx *Context) SetOutput(w io.Writer)

func (*Context) SetPrompt

func (ctx *Context) SetPrompt(f string)

func (*Context) WriteHistory

func (ctx *Context) WriteHistory() (int, error)

type Register

type Register interface {
	Commands
	Register(Command)
}

func NewRegister

func NewRegister() Register

func NewRegisterWithDB

func NewRegisterWithDB(db *bolt.DB) Register

type Usage

type Usage interface {
	Usage() string
}

type ValidateFunc

type ValidateFunc func(ctx *Context, args []string) error

type Validates

type Validates []ValidateFunc

func NewValidats

func NewValidats() Validates

func (Validates) Append

func (v Validates) Append(f ValidateFunc) Validates

func (Validates) Choices

func (v Validates) Choices(pos int, choices []string) Validates

func (Validates) Finish

func (v Validates) Finish() ValidateFunc

func (Validates) MaxArgs

func (v Validates) MaxArgs(n int) Validates

func (Validates) MinArgs

func (v Validates) MinArgs(n int) Validates

func (Validates) NumArgs

func (v Validates) NumArgs(n int) Validates

func (Validates) NumArgsChoice

func (v Validates) NumArgsChoice(n ...int) Validates

Jump to

Keyboard shortcuts

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