import "github.com/egdaemon/eg/runtime/wasi/shell"

func Run

func Run(ctx context.Context, cmds ...Command) (err error)

type Command

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

func New

func New(cmd string) Command

New create a new command with reasonable defaults. defaults:

timeout: 5 minutes.

func Newf

func Newf(cmd string, options ...any) Command

Newf provides a simple printf form of creating commands.

func Runtime

func Runtime() Command

Runtime creates a Command with no specified command to run. and can be used as a template:

tmp := shell.Runtime().Environ("FOO", "BAR")

shell.Run(

tmp.New("ls -lha"),
tmp.New("echo hello world"),

)

func (Command) Attempts

func (t Command) Attempts(a int16) Command

number of attempts to make before giving up.

func (Command) Directory

func (t Command) Directory(d string) Command

directory to run the command in. must be a relative path.

func (Command) Environ

func (t Command) Environ(k, v string) Command

append a specific key/value environment variable.

func (Command) EnvironFrom

func (t Command) EnvironFrom(environ ...string) Command

append a set of environment variables in the form KEY=VALUE to the environment.

func (Command) Lenient

func (t Command) Lenient(d bool) Command

directory to run the command in. must be a relative path.

func (Command) New

func (t Command) New(cmd string) Command

New clone the current command configuration and replace the command that will be executed.

func (Command) Newf

func (t Command) Newf(cmd string, options ...any) Command

Newf provides a simple printf form of creating commands.

func (Command) Timeout

func (t Command) Timeout(d time.Duration) Command

maximum duration for a command to run.