Documentation
¶
Index ¶
- func ReplaceShellSession(spec *ExecSpec) error
- func RunShellSession(ctx context.Context, spec *ShellSessionSpec) error
- func RunShellStep(ctx context.Context, spec *ShellSessionSpec, plain func() error) error
- type DefaultRunner
- type ExecSpec
- type Result
- type Runner
- type ShellSessionSpec
- type Streams
- type TaskSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceShellSession ¶
ReplaceShellSession replaces the Atmos process with the spec's command (execve of the system shell). On success it never returns: the command inherits the terminal, file descriptors, environment, and working directory, and its exit code becomes the process exit code natively. It returns an error only if the replacement could not be performed (or nil for dry-run).
func RunShellSession ¶
func RunShellSession(ctx context.Context, spec *ShellSessionSpec) error
RunShellSession executes a shell command attached to the user's terminal.
When TTY is set and the platform supports it, the command runs under a pseudo-terminal: output masking is preserved, and (with Interactive) the host terminal switches to raw mode so Ctrl-C reaches the child instead of Atmos. Otherwise the command inherits the real stdin/stdout/stderr file descriptors directly; masking is unavailable in that mode.
Non-zero exits are returned as errUtils.ExitCodeError.
func RunShellStep ¶
func RunShellStep(ctx context.Context, spec *ShellSessionSpec, plain func() error) error
RunShellStep routes a shell-family step: steps that request a terminal (tty and/or interactive) run as terminal-attached sessions; plain steps run via the caller-provided fallback (each execution path keeps its own plain-step behavior: masked interpreter, command runner, output modes).
Types ¶
type ExecSpec ¶
type ExecSpec struct {
// Command is the raw shell command string, run via the system shell.
Command string
// Name is a logical name used for logging.
Name string
// Dir is the working directory to change to before the replacement ("" keeps the current directory).
Dir string
// Env is the fully merged environment, used verbatim. ATMOS_SHLVL is NOT
// incremented: the session replaces Atmos rather than nesting under it.
Env []string
// DryRun logs the command without executing it.
DryRun bool
}
ExecSpec describes an exec step: a command that replaces the Atmos process entirely (shell exec semantics). Exec steps must be the final step — nothing runs after the replacement, and supervisor features (masking, output capture, retry, timeout) do not apply.
type Result ¶
type Result struct {
Command string
Args []string
ExitCode int
Err error
Started bool
Canceled bool
StartedAt time.Time
FinishedAt time.Time
}
Result contains the outcome of a subprocess invocation.
type Runner ¶
Runner executes a task and returns the observed process result.
func NewDefaultRunner ¶
func NewDefaultRunner() Runner
NewDefaultRunner returns a Runner backed by os/exec.
type ShellSessionSpec ¶
type ShellSessionSpec struct {
// Command is the raw shell command string, run via the system shell.
Command string
// Name is a logical name used for logging.
Name string
// Dir is the working directory.
Dir string
// Env is the fully merged environment. When empty, os.Environ() is used.
Env []string
// TTY allocates a pseudo-terminal when the platform supports it.
TTY bool
// Interactive forwards host stdin to the session and suspends the Atmos
// SIGINT-exit handler so Ctrl-C is handled by the child process.
Interactive bool
// DryRun logs the command without executing it.
DryRun bool
// Masker applies secret masking to PTY output. When nil, it defaults to
// iolib.GetContext().Masker() with EnableMasking from the `mask` setting,
// so call sites don't need masking wiring.
Masker iolib.Masker
// EnableMasking enables secret masking of session output where supported.
EnableMasking bool
}
ShellSessionSpec describes a shell step that attaches to the user's terminal (steps declared with `tty: true` and/or `interactive: true`).