Logo ProcessKit API Reference

Exec Module

Top-level conveniences: run a program by name (without first building a `Command`), and run a whole batch of commands with bounded concurrency. The single-command verbs are zero-config one-liners (for cancellation, build a `Command` and use its verbs, or go through `Runner`); the batch verbs take an explicit `CancellationToken` so a long fan-out can be cancelled.

Functions and values

Function or value Description

Exec.outputAll concurrency runner commands cancellationToken

Full Usage: Exec.outputAll concurrency runner commands cancellationToken

Parameters:
Returns: Task<Result<ProcessResult<string>, ProcessError>[]>

Run every command in `commands` through `runner`, keeping at most `concurrency` live at once, and collect all results (decoded text) in input order. Each element is one command's independent `Result`; the batch never short-circuits on a failure.

concurrency : int
runner : IProcessRunner
commands : Command seq
cancellationToken : CancellationToken
Returns: Task<Result<ProcessResult<string>, ProcessError>[]>

Exec.outputAllBytes concurrency runner commands cancellationToken

Full Usage: Exec.outputAllBytes concurrency runner commands cancellationToken

Parameters:
Returns: Task<Result<ProcessResult<byte[]>, ProcessError>[]>

The raw-bytes companion to `outputAll` — captures each command's stdout as bytes.

concurrency : int
runner : IProcessRunner
commands : Command seq
cancellationToken : CancellationToken
Returns: Task<Result<ProcessResult<byte[]>, ProcessError>[]>

Exec.outputBytes program args

Full Usage: Exec.outputBytes program args

Parameters:
    program : string
    args : string seq

Returns: Task<Result<ProcessResult<byte[]>, ProcessError>>

The raw-bytes companion to `outputString` — captures `program`'s stdout as bytes.

program : string
args : string seq
Returns: Task<Result<ProcessResult<byte[]>, ProcessError>>

Exec.outputString program args

Full Usage: Exec.outputString program args

Parameters:
    program : string
    args : string seq

Returns: Task<Result<ProcessResult<string>, ProcessError>>

Run `program` with `args` to completion and return the full `ProcessResult` (a non-zero exit is data, not an error).

program : string
args : string seq
Returns: Task<Result<ProcessResult<string>, ProcessError>>

Exec.run program args

Full Usage: Exec.run program args

Parameters:
    program : string
    args : string seq

Returns: Task<Result<string, ProcessError>>

Run `program` with `args` in a private kill-on-dispose group, require a zero/accepted exit, and return stdout with trailing whitespace trimmed.

program : string
args : string seq
Returns: Task<Result<string, ProcessError>>

Exec.which program

Full Usage: Exec.which program

Parameters:
    program : string

Returns: Result<string, ProcessError>

Resolve `program` to a full path without spawning it — a preflight/`doctor`-style check ("is this tool installed?") with no side effects, unlike probing availability by actually running the program (`ProbeAsync`). Reuses the exact PATH/PATHEXT-aware logic the spawn path itself falls back on to name the directories it searched (`Native.Common.resolveProgram`), so `which` and an actual spawn of the same `program` never disagree on found-vs-not-found. Returns the resolved full path on success, or a typed `ProcessError.NotFound` — `Searched` names the `PATH` value that was probed when `program` is a bare name (e.g. `"git"`), and is `None` when `program` already names a path (e.g. `"./tool"`, `"/usr/bin/tool"`), since a path-form program is checked directly and never searched.

program : string
Returns: Result<string, ProcessError>

Type something to start searching.