commands

package
v0.0.0-...-75e3e40 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCommands = Commands{}

Functions

func Append

func Append(c Command)

func PrintUsage

func PrintUsage()

func Run

func Run() error

Types

type Base

type Base struct {
	Usage       string
	Short, Long string

	Flags *flag.FlagSet
}

Base implements the boring parts of the Command interface.

func (*Base) FlagSet

func (c *Base) FlagSet() *flag.FlagSet

func (*Base) Listing

func (c *Base) Listing() string

Listing returns command name and short help separated by tab

func (*Base) Name

func (c *Base) Name() string

func (*Base) PrintUsage

func (c *Base) PrintUsage()

type Command

type Command interface {
	// Name of the command
	Name() string

	// PrintUsage block to os.Stdout
	PrintUsage()

	// Short listing consisting of name and short help separated by tab
	Listing() string

	// FlagSet for this command
	FlagSet() *flag.FlagSet

	// Callback
	Run() error
}

func Find

func Find(name string) Command

type Commands

type Commands []Command

func (Commands) Find

func (c Commands) Find(name string) Command

func (Commands) PrintUsage

func (c Commands) PrintUsage()

func (Commands) Run

func (c Commands) Run() error

Run finds the correct subcommand and runs it.

Jump to

Keyboard shortcuts

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