cmds

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CmdLs    = FuncCmd(ls)
	CmdPwd   = FuncCmd(pwd)
	CmdCd    = FuncCmd(cd)
	CmdUname = FuncCmd(uname)
	CmdEnv   = FuncCmd(env)
)

Functions

This section is empty.

Types

type Command

type Command interface {
	Run(runner *CommandRunner, args ...string) error
}

type CommandRunner

type CommandRunner struct {
	C *conf.FakeshellConfig

	Env     *EnvMap
	TempEnv *EnvMap
	RootFS  afero.Fs

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

func NewCommandRunner

func NewCommandRunner(c *conf.FakeshellConfig) *CommandRunner

func (*CommandRunner) GetEnv

func (r *CommandRunner) GetEnv(key string) string

func (*CommandRunner) GetEnvs

func (r *CommandRunner) GetEnvs() []EnvPair

func (*CommandRunner) Run

func (r *CommandRunner) Run(cmdPar *parser.Command, cmdOp Command) error

func (*CommandRunner) SetEnv

func (r *CommandRunner) SetEnv(key, value string)

func (*CommandRunner) UnsetEnv

func (r *CommandRunner) UnsetEnv(key string)

type EnvMap

type EnvMap struct {
	Envs xsync.MapOf[string, EnvPair]
}

func NewEnvMap

func NewEnvMap(m map[string]string) *EnvMap

func (*EnvMap) Get

func (e *EnvMap) Get(key string) string

type EnvPair

type EnvPair struct {
	Key   string
	Value string
}

type FuncCmd

type FuncCmd func(runner *CommandRunner, args ...string) error

func (FuncCmd) Run

func (f FuncCmd) Run(runner *CommandRunner, args ...string) error

Jump to

Keyboard shortcuts

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