cmd

package
v0.0.0-...-c130b31 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2018 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAbortCommand = errors.New("")

Functions

func Colorfy

func Colorfy(msg string, fontcolor string, background string, effect string) string

func ExtractProgramName

func ExtractProgramName(path string) string

func JoinWithUserDir

func JoinWithUserDir(p ...string) string

func MergeFlagSet

func MergeFlagSet(fs1, fs2 *gnuflag.FlagSet) *gnuflag.FlagSet

Types

type AdminCommandable

type AdminCommandable interface {
	AdminCommands() []Command
}

Implementing the AdminCommandable interface allows extending the megamd admin command line interface

type Command

type Command interface {
	Info() *Info
	Run(context *Context) error
}

type Commandable

type Commandable interface {
	Commands() []Command
}

Implementing the Commandable interface allows extending the megamd command line interface

type ConfirmationCommand

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

func (*ConfirmationCommand) Confirm

func (cmd *ConfirmationCommand) Confirm(context *Context, question string) bool

func (*ConfirmationCommand) Flags

func (cmd *ConfirmationCommand) Flags() *gnuflag.FlagSet

type Context

type Context struct {
	Args   []string
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader
}

type DeprecatedCommand

type DeprecatedCommand struct {
	Command
	// contains filtered or unexported fields
}

func (*DeprecatedCommand) Flags

func (c *DeprecatedCommand) Flags() *gnuflag.FlagSet

func (*DeprecatedCommand) Run

func (c *DeprecatedCommand) Run(context *Context) error

type FlaggedCommand

type FlaggedCommand interface {
	Command
	Flags() *gnuflag.FlagSet
}

type Info

type Info struct {
	Name    string
	MinArgs int
	MaxArgs int
	Usage   string
	Desc    string
}

type Lookup

type Lookup func(context *Context) error

type Manager

type Manager struct {
	Commands map[string]Command
	// contains filtered or unexported fields
}

func BuildBaseManager

func BuildBaseManager(name, version string, lookup Lookup, mode Mode) *Manager

func NewManager

func NewManager(name, ver string, stdout, stderr io.Writer, stdin io.Reader, lookup Lookup, mode Mode) *Manager

func (*Manager) Register

func (m *Manager) Register(command Command)

func (*Manager) RegisterDeprecated

func (m *Manager) RegisterDeprecated(command Command, oldName string)

func (*Manager) RegisterTopic

func (m *Manager) RegisterTopic(name, content string)

func (*Manager) Run

func (m *Manager) Run(args []string)

type MapFlag

type MapFlag map[string]string

func (*MapFlag) Set

func (f *MapFlag) Set(val string) error

func (*MapFlag) String

func (f *MapFlag) String() string

type Mode

type Mode func(modelvl int)

type Row

type Row []string

type StringSliceFlag

type StringSliceFlag []string

func (*StringSliceFlag) Set

func (f *StringSliceFlag) Set(val string) error

func (*StringSliceFlag) String

func (f *StringSliceFlag) String() string

type Table

type Table struct {
	Headers       Row
	LineSeparator bool
	// contains filtered or unexported fields
}

func NewTable

func NewTable() *Table

func (*Table) AddRow

func (t *Table) AddRow(row Row)

func (*Table) Bytes

func (t *Table) Bytes() []byte

func (*Table) Reverse

func (t *Table) Reverse()

func (*Table) Rows

func (t *Table) Rows() int

func (*Table) Sort

func (t *Table) Sort()

Sort sorts the rows in the table using the first column as key.

func (*Table) SortByColumn

func (t *Table) SortByColumn(column int)

func (*Table) String

func (t *Table) String() string

Jump to

Keyboard shortcuts

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