cmd

package
v0.0.0-...-3f733d8 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsParseErr

func IsParseErr(err error) (is bool)

Types

type ByLength

type ByLength []string

func (ByLength) Len

func (b ByLength) Len() int

func (ByLength) Less

func (b ByLength) Less(i, j int) bool

func (ByLength) Swap

func (b ByLength) Swap(i, j int)

type CmdFn

type CmdFn func(Context) error

CmdFn is a function implementation of Cmder.

func (CmdFn) Cmd

func (c CmdFn) Cmd(cx Context) error

Cmd implements Cmder on CmdFn.

type Cmder

type Cmder interface {
	Cmd(Context) error
}

Cmder is a simple CLI command interface.

func Parse

func Parse(args ...string) (cc Cmder, err error)

Parse consumes a list of command-line arguments to return a Cmder.

type Config

type Config struct{}

func (Config) Cmd

func (c Config) Cmd(ct Context) error

func (Config) Help

func (Config) Help() string

func (*Config) Parse

func (c *Config) Parse(arg string) (Cmder, error)

func (Config) Short

func (Config) Short() string

type ConfigGet

type ConfigGet []string

func (*ConfigGet) Cmd

func (c *ConfigGet) Cmd(ct Context) error

func (*ConfigGet) Parse

func (c *ConfigGet) Parse(arg string) (is Cmder, err error)

type ConfigLister

type ConfigLister struct{}

type ConfigSet

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

func (*ConfigSet) Cmd

func (c *ConfigSet) Cmd(ct Context) error

func (*ConfigSet) Parse

func (c *ConfigSet) Parse(next string) (Cmder, error)

type Context

type Context struct {
	config.Config

	*bufio.Writer
	*bolt.DB
}

type DB

type DB interface {
	WantsDB()
}

Commands which implement DB want a database connection.

type Do

type Do struct{}

func (Do) Cmd

func (Do) Cmd(_ Context) error

func (Do) Help

func (Do) Help() string

func (Do) Short

func (Do) Short() string

type Help

type Help struct{ Helper }

func (*Help) Cmd

func (h *Help) Cmd(ctx Context) (err error)

func (Help) Help

func (Help) Help() (is string)

func (*Help) Parse

func (h *Help) Parse(next string) (cc Cmder, err error)

func (Help) Short

func (Help) Short() string

type Helper

type Helper interface {
	Short() string
	Help() string
}

Helper defines a short description and a longer help message for use in a help page.

type Init

type Init struct{}

func (Init) Cmd

func (Init) Cmd(ctx Context) error

func (Init) Help

func (Init) Help() string

func (Init) Short

func (Init) Short() string

type Live

type Live struct{ DB }

func (Live) Cmd

func (Live) Cmd(c Context) error

func (Live) Help

func (Live) Help() string

func (Live) Short

func (Live) Short() string

type Mode

type Mode struct{}

func (Mode) Cmd

func (Mode) Cmd(_ Context) error

func (Mode) Help

func (Mode) Help() string

func (Mode) Short

func (Mode) Short() string

type ParseErr

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

type Parser

type Parser interface {
	Parse(arg string) (Cmder, error)
}

Parser consumes command-line arguments to return a Cmder. Idea: Use Parser with Help to validate example usage!

type Printer

type Printer string

func (Printer) Cmd

func (p Printer) Cmd(ctx Context) (err error)

type Pub

type Pub struct{}

func (Pub) Cmd

func (Pub) Cmd(_ Context) error

func (Pub) Help

func (Pub) Help() string

func (Pub) Short

func (Pub) Short() string

type Sub

type Sub struct{}

func (Sub) Cmd

func (Sub) Cmd(_ Context) error

func (Sub) Help

func (Sub) Help() string

func (Sub) Short

func (Sub) Short() string

type Task

type Task struct{}

func (Task) Cmd

func (Task) Cmd(_ Context) error

func (Task) Help

func (Task) Help() string

func (Task) Short

func (Task) Short() string

type Version

type Version struct{}

func (Version) Cmd

func (v Version) Cmd(c Context) error

func (Version) Help

func (Version) Help() (is string)

func (Version) Short

func (Version) Short() string

Jump to

Keyboard shortcuts

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