Expand description
gwm exec (issue #313): run a command across worktrees and roll up the
results.
The CLI handler in cli.rs resolves which worktrees to target and prints
the output; everything testable lives here: the spawn primitive
(exec_in_dir), the aggregate exit code (rollup_exit_code), and the
per-worktree line formatter (format_outcome). Execution is sequential
— deterministic, readable output for the MVP; parallel fan-out is a
deliberate follow-up.
Structs§
- Exec
Outcome - A worktree’s display name paired with its command outcome.
Enums§
- Exec
Status - Outcome of running the command inside one worktree.
Functions§
- exec_
capture_ in_ dir - Like
exec_in_dir, but CAPTURE stdout+stderr (stdout then stderr) instead of inheriting the parent’s stdio. Used byrun_in_dirs_parallelso concurrent worktrees don’t interleave their output — each block is printed whole, in worktree order, after the fan-out completes. - exec_
in_ dir - Run
program args…with the working directory set todir. - format_
outcome - Render one rollup line for a worktree using the repo’s ✓ / ✗ sigils,
e.g.
✓ feat-1or✗ fix-2 (exit 2). - resolve_
exec_ command - Resolve the argv
gwm execshould run, from exactly one source: an inline-- <cmd>or a--profile <name>(issue #324). - resolve_
jobs - Resolve the effective parallelism for
gwm exec(issue #324): the--jobsflag wins, then the selected profile’sjobs, then the global[exec] jobs, else1. A resolved0(or absent) means sequential. Always returns a worker count>= 1. - resolve_
program - Resolve
programfor execution insidedir. - rollup_
exit_ code - Aggregate exit code for the whole fan-out:
0only when every worktree succeeded, else1. Mirrors the repo’s doctor/CI convention of a single non-zero “something failed” code rather than trying to reconcile multiple distinct child codes into one. - run_
in_ dirs_ parallel - Run
program args…in each(name, dir)ofitemswith up tojobsconcurrent workers, capturing each one’s output. Returns one(ExecOutcome, captured_output)per item in input order (not completion order), so the caller prints deterministic per-worktree blocks regardless of which finished first.jobsis clamped to[1, items.len()]. - validate_
exec_ profile_ command - Validate a
[exec.profiles.<name>]entry’scommand: it must be a non-empty argv array. Surfaced for the config validation path sogwm config validate/gwm doctorreject whatgwm exec --profilewould (issue #324 review).
Type Aliases§
- Captured
Run - One parallel worktree run: its
ExecOutcomeplus the captured stdout+stderr bytes printed as a block by the caller.