run_cli()

Run a CLI command to completion and return its stdout.

Usage

Source

run_cli(
    argv,
    *,
    input=None,
    timeout=30,
    env=None,
    cwd=None,
)

Parameters

argv: list[str]

The command and its arguments.

input: str | None = None

Text delivered to the process over stdin.

timeout: int = 30

Seconds to wait before the process is killed.

env: dict[str, str] | None = None

Environment for the process; None inherits the current environment.

cwd: str | None = None
Working directory for the process.

Returns

str
The decoded stdout.

Raises

subprocess.CalledProcessError

On a nonzero exit code, with the argv, exit code, and stdout/stderr tails attached as notes.

subprocess.TimeoutExpired
When the process outlives timeout.