Expand description
The single shell-out primitive.
Every external command a step-graph tool runs goes through run (or one
of its variants) so command execution is logged + classified in one place.
A sequential orchestrator gains nothing from async here, so this is
deliberately synchronous std::process, which keeps step bodies plain.
Hang protection: commands that can block indefinitely on the network (curl)
pass their own bounding flags (--max-time, --connect-timeout).
Long steps (package installs, clones, builds) also have a streaming
variant, run_streamed, which pipes the child’s stdout+stderr and hands
each line to a callback as it arrives so a live UI can show real activity
instead of a bare spinner. The plain run stays for the many short
commands where all-at-once capture is simpler. run_cmd and
run_streamed_cmd take a pre-built Command for callers that set a
working directory or environment.
Structs§
- CmdResult
- Outcome of one external command.
codeisNonewhen the process could not be spawned at all (binary missing on PATH);spawneddistinguishes that from a non-zero exit.
Functions§
- run
- Run
program args..., capturing stdout/stderr. Never panics: a spawn failure (missing binary) yields aCmdResult { code: None, spawned: false }rather than an error, so callers decide whether a missing tool is fatal. - run_
checked - Run a command that MUST succeed; returns the captured result or an error carrying the trimmed stderr. Use inside Required steps.
- run_cmd
- Like
runbut takes a pre-builtCommand(so the caller can set the working directory + environment) and captures the FULL stdout/stderr with no line cap: use when the output is parsed and may be long (e.g. a PEM key), unlike the streaming runners which keep only a bounded tail. - run_ok
- Convenience: run and report only whether it exited 0. Use for best-effort commands where the output is not needed.
- run_
streamed - Run
program args..., streaming each stdout/stderr line toon_lineas it arrives. Returns the sameCmdResultshape asrun, butstdout/stderrcarry only the trailing 120 lines of each stream (so ananyhow::bail!(…, res.stderr.trim())caller still reports the real error).on_lineruns on the calling thread, so it can borrow non-Sendstate (the progress sink) freely. - run_
streamed_ cmd - Like
run_streamedbut takes a pre-builtCommand, so the caller can set the working directory + environment. Streams stdout/stderr lines toon_lineon the calling thread. - run_
with_ stdin - Run
program args...withinputwritten to its stdin, capturing stdout/stderr likerun. For secrets a command can read from stdin (a Wi-Fi passphrase), so they never appear in the process argv (readable by every local user through/proc/<pid>/cmdline) or in this module’s logs:inputis never logged.