Documentation ¶
Overview ¶
Package shell implements spok's command running functionality
We use https://github.com/mvdan/sh so spok is entirely self contained and does not need an external shell at all to run.
This implementation is based on a similar one in https://github.com/go-task/task at internal/execext/exec.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntegratedRunner ¶
type IntegratedRunner struct {
// contains filtered or unexported fields
}
IntegratedRunner implements Runner by using a 100% go implementation of a shell interpreter, this is the most cross-compatible version of a shell runner possible as it does not depend on any external shell.
func NewIntegratedRunner ¶
func NewIntegratedRunner() IntegratedRunner
NewIntegratedRunner returns a shell runner with no external dependency.
func (IntegratedRunner) Run ¶
func (i IntegratedRunner) Run(cmd string, stream iostream.IOStream, task string, env []string) (Result, error)
Run implements Runner for an IntegratedRunner, using a 100% go implementation of a shell interpreter.
Command stdout and stderr will be collected into the returned Result and optionally also printed to the writers in the IOStream, this allows output to be captured or discarded easily.
type Result ¶
type Result struct { Cmd string `json:"cmd"` // The command that was run Stdout string `json:"stdout"` // The stdout of the command Stderr string `json:"stderr"` // The stderr of the command Status int `json:"status"` // The exit status of the command }
Result holds the result of running a shell command.
type Runner ¶
type Runner interface { // Run runs the shell command belonging to task with environment variables set. Run(cmd string, stream iostream.IOStream, task string, env []string) (Result, error) }
Runner is an interface representing something capable of running shell commands and returning Results.