cmd

package
v0.0.0-...-ebeccf4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 21 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

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

	// ErrLookup is the error that should be returned by lookup functions when it
	// cannot find a matching command for the given parameters.
	ErrLookup = errors.New("lookup error - command not found")
)

Functions

func Colorfy

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

func ExtractProgramName

func ExtractProgramName(path string) string

func PasswordFromReader

func PasswordFromReader(reader io.Reader) (string, error)

func RegisterExtraCmd

func RegisterExtraCmd(cmd Command)

Types

type Cancelable

type Cancelable interface {
	// Cancel handles the command cancellation and is required to be thread safe as
	// this method is called by a different goroutine.
	// Cancel should return an error if the operation is not cancelable yet/anymore or there
	// was any error during the cancellation.
	// Cancel may be called multiple times.
	Cancel(context Context) error
}

Cancelable are implemented by commands that support cancellation

type Command

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

func ExtraCmds

func ExtraCmds() []Command

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
}

func (*Context) RawOutput

func (c *Context) RawOutput()

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
	// contains filtered or unexported fields
}

type Lookup

type Lookup func(context *Context) error

type Manager

type Manager struct {
	Commands  map[string]Command
	RetryHook func(err error) (retry bool)
	// contains filtered or unexported fields
}

func NewManager

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

This is discouraged: use NewManagerPanicExiter instead. Handle panic(*PanicExitError) accordingly

func NewManagerPanicExiter

func NewManagerPanicExiter(name string, stdout, stderr io.Writer, stdin io.Reader, lookup Lookup) *Manager

When using this, you should handle panic(*PanicExitError) accordingly

func (*Manager) Register

func (m *Manager) Register(command Command)

func (*Manager) RegisterDeprecated

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

func (*Manager) RegisterRemoved

func (m *Manager) RegisterRemoved(name string, help string)

func (*Manager) RegisterTopic

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

func (*Manager) Run

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

func (*Manager) SetExiter

func (m *Manager) SetExiter(e exiter)

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 MapFlagWrapper

type MapFlagWrapper struct {
	Dst *map[string]string
}

func (MapFlagWrapper) Set

func (f MapFlagWrapper) Set(val string) error

func (MapFlagWrapper) String

func (f MapFlagWrapper) String() string

type PanicExitError

type PanicExitError struct {
	Code int
}

func (*PanicExitError) Error

func (e *PanicExitError) Error() string

type PanicExiter

type PanicExiter struct{}

func (PanicExiter) Exit

func (e PanicExiter) Exit(code int)

type RemovedCommand

type RemovedCommand struct {
	Name string
	Help string
}

func (*RemovedCommand) Info

func (c *RemovedCommand) Info() *Info

func (*RemovedCommand) Run

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

type StringSliceFlag

type StringSliceFlag []string

func (*StringSliceFlag) Set

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

func (*StringSliceFlag) String

func (f *StringSliceFlag) String() string

type StringSliceFlagWrapper

type StringSliceFlagWrapper struct {
	Dst *[]string
}

func (StringSliceFlagWrapper) Set

func (f StringSliceFlagWrapper) Set(val string) error

func (StringSliceFlagWrapper) String

func (f StringSliceFlagWrapper) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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