import "github.com/egdaemon/eg/runtime/wasi/shell"
<a name="Op"></a>
func Op(cmds ...Command) eg.OpFn
Convience function for running a set of commands as an operation.
<a name="Run"></a>
func Run(ctx context.Context, cmds ...Command) (err error)
Run the provided commands using the operation.
<a name="Command"></a>
type Command struct {
// contains filtered or unexported fields
}
<a name="New"></a>
func New(cmd string) Command
New create a new command with reasonable defaults. defaults:
timeout: 5 minutes.
<a name="Newf"></a>
func Newf(cmd string, options ...any) Command
Newf provides a simple printf form of creating commands.
<a name="Runtime"></a>
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"),
)
<a name="Command.As"></a>
func (t Command) As(u string) Command
convience function that sets both user and group to the provided value.
<a name="Command.Attempts"></a>
func (t Command) Attempts(a int16) Command
number of attempts to make before giving up.
<a name="Command.Directory"></a>
func (t Command) Directory(d string) Command
directory to run the command in. must be a relative path.
<a name="Command.Environ"></a>
func (t Command) Environ(k string, v any) Command
append a specific key/value environment variable.
<a name="Command.EnvironFrom"></a>
func (t Command) EnvironFrom(environ ...string) Command
append a set of environment variables in the form KEY=VALUE to the environment.
<a name="Command.Group"></a>
func (t Command) Group(g string) Command
group to run the command as
<a name="Command.Lenient"></a>
func (t Command) Lenient(d bool) Command
directory to run the command in. must be a relative path.
<a name="Command.New"></a>
func (t Command) New(cmd string) Command
New clone the current command configuration and replace the command that will be executed.
<a name="Command.Newf"></a>
func (t Command) Newf(cmd string, options ...any) Command
Newf provides a simple printf form of creating commands.
<a name="Command.Privileged"></a>
func (t Command) Privileged() Command
specialized for As("root") which runs the command as root.
<a name="Command.Timeout"></a>
func (t Command) Timeout(d time.Duration) Command
maximum duration for a command to run. default is 5 minutes.
<a name="Command.UnsafeEntrypoint"></a>
func (t Command) UnsafeEntrypoint(e entrypoint) Command
Internal use only not under compatability promises.
<a name="Command.User"></a>
func (t Command) User(u string) Command
user to run the command as
<a name="Recorder"></a>
type Recorder struct {
// contains filtered or unexported fields
}
<a name="NewRecorder"></a>
func NewRecorder(cmd *Command) *Recorder
creates a recorder that allows for generating string representations of commands for tests.
<a name="Recorder.Hijack"></a>
func (t *Recorder) Hijack(cmd *Command) error
<a name="Recorder.Record"></a>
func (t *Recorder) Record(ctx context.Context, dir string, environ []string, cmd string, args []string) error
<a name="Recorder.Result"></a>
func (t *Recorder) Result() string