sh_command

package
v0.0.0-...-e73a948 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultExecuter = makeDefaultExecuter()
View Source
var ExitErr error = exitErr{}
View Source
var UnfinishedErr = errors.New("Unfinished string")

Functions

func Execute

func Execute(src Source, name string, args ...string) (err error)

func ExecuteCommand

func ExecuteCommand(src Source, cmd string) (err error)

func ParseCommand

func ParseCommand(src string) (args []string, err error)

Types

type Command

type Command interface {
	Execute(src Source, args ...string) error
}

type CommandMap

type CommandMap map[string]Command

func (CommandMap) Add

func (m CommandMap) Add(name string, cmd Command)

func (CommandMap) Get

func (m CommandMap) Get(name string) (cmd Command, ok bool)

func (CommandMap) Len

func (m CommandMap) Len() int

type EchoCmd

type EchoCmd struct{}

func (EchoCmd) Execute

func (EchoCmd) Execute(src Source, args ...string) (err error)

type Executer

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

func NewExecuter

func NewExecuter() *Executer

func (*Executer) Execute

func (e *Executer) Execute(src Source, name string, args ...string) (err error)

func (*Executer) Register

func (e *Executer) Register(name string, cmd Command) *Executer

type ExitCmd

type ExitCmd struct{}

func (ExitCmd) Execute

func (ExitCmd) Execute(src Source, args ...string) error

type ShellCmd

type ShellCmd struct{}

func (ShellCmd) Execute

func (ShellCmd) Execute(src Source, args ...string) (err error)

type Source

type Source interface {
	io.Reader
	io.Writer

	Print(args ...interface{}) (int, error)
	Println(args ...interface{}) (int, error)
	Printf(format string, args ...interface{}) (int, error)
}

func NewSource

func NewSource(r io.Reader, w io.Writer) Source

type UnknownCommand

type UnknownCommand struct {
	Name string
}

func (*UnknownCommand) Error

func (e *UnknownCommand) Error() string

Jump to

Keyboard shortcuts

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