Skip to main content

run_subprocess

Function run_subprocess 

Source
pub async fn run_subprocess<F>(
    logger: &mut Logger,
    cmd_builder: F,
    stderr_lines: Option<usize>,
) -> Result<SubprocessOutput>
where F: FnOnce() -> CommandBuilder,
Expand description

Run a subprocess with piped stdout/stderr, capturing stdout fully while rendering stderr lines live in a ring buffer.

§Arguments

  • logger - Logger instance to manage progress bar suspension/clearing
  • cmd_builder - Closure that builds a portable_pty::CommandBuilder
  • stderr_lines - Number of stderr lines to show in the scrolling region (default: 5)

§Behavior

  • Uses PTY mode so subprocesses see a TTY (preserves ANSI colors)
  • Sets up a scrolling region at the bottom of the terminal
  • Suspends/clears any active progress bar before running
  • Captures stdout fully
  • Renders stderr lines live in the scrolling region
  • On success: clears the scrolling region cleanly
  • On failure: leaves/replays the final window

§Returns

Returns SubprocessOutput with captured stdout, stderr, and exit status.