Documentation
¶
Overview ¶
Package shell provides POSIX shell command execution actions for the operation graph.
Commands are run via `sh -c <command>` — POSIX shell semantics, available on Linux, macOS, and any platform with `sh` on PATH. For PowerShell 7+ execution see pkg/op/provider/powershell.
Returns a Result with the original command, both captured streams, and the subprocess exit code so the value can be Emitted to a [result.Sink] (JSON, YAML, or CSV) and returned to the caller in one shape.
Index ¶
Constants ¶
const (
Exec op.ActionName = "shell.exec"
)
Action-name constants for the shell provider's plan-mode actions.
Each constant is the short dotted action label its method dispatches under. Pass these to plan.Plan, op.ReceiverRegistry().BuildAction, RuntimeEnvironment.ActionByName, or WithActionNamed in place of a string literal so a typo is a compile error and rename / find-references work through the constant.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
op.ProviderBase
}
Provider provides shell command execution.
+devlore:access=planned
func NewProvider ¶
func NewProvider(runtimeEnvironment *op.RuntimeEnvironment) *Provider
NewProvider constructs a POSIX shell Provider bound to the given runtime environment.
Parameters:
- `runtimeEnvironment`: the runtime environment that supplies the subprocess context, status sink, and result sink.
Returns:
- `*Provider`: the initialized provider.
func (*Provider) Exec ¶
Exec executes a POSIX shell command and returns the structured execution result.
Parameters:
- `command`: shell command string to execute via sh -c.
Returns:
- `*Result`: command, both captured streams, and the exit code; nil only when command is empty.
- `error`: any error from cmd.Run (the result is still returned with whatever was captured).
type Result ¶
type Result struct {
// Command is the command string passed to the shell.
Command string `json:"command" yaml:"command" csv:"command"`
// ExitCode is the subprocess exit code; 0 on success.
ExitCode int `json:"exit" yaml:"exit" csv:"exit"`
// Stderr holds the captured stderr bytes as a string.
Stderr string `json:"stderr" yaml:"stderr" csv:"stderr"`
// Stdout holds the captured stdout bytes as a string.
Stdout string `json:"stdout" yaml:"stdout" csv:"stdout"`
}
Result is the structured outcome of a shell command execution.
Carries the original command, both captured streams, and the subprocess exit code so the value can be Emitted to a [result.Sink] (JSON, YAML, or CSV) and returned to the caller in one shape.