Logo ProcessKit API Reference

Command Module

Pipe-friendly functions over `Command`, mirroring the instance **builder** methods. The run verbs (`RunAsync`/`OutputStringAsync`/`ParseAsync`/…) are instance methods only — end a pipeline with method syntax (`(cmd |> Command.arg "x").RunAsync()`), or go through `Runner.*` with an explicit runner.

Functions and values

Function or value Description

Command.arg value command

Full Usage: Command.arg value command

Parameters:
Returns: Command

Append a single argument.

value : string
command : Command
Returns: Command

Command.args values command

Full Usage: Command.args values command

Parameters:
    values : string seq
    command : Command

Returns: Command

Append several arguments, in order.

values : string seq
command : Command
Returns: Command

Command.cancelOn cancellationToken command

Full Usage: Command.cancelOn cancellationToken command

Parameters:
Returns: Command

Also cancel the run when `cancellationToken` fires.

cancellationToken : CancellationToken
command : Command
Returns: Command

Command.create program

Full Usage: Command.create program

Parameters:
    program : string

Returns: Command

Create a command for the given program.

program : string
Returns: Command

Command.createNoWindow command

Full Usage: Command.createNoWindow command

Parameters:
Returns: Command

Windows: run the child with `CREATE_NO_WINDOW` (no effect on Unix).

command : Command
Returns: Command

Command.currentDir directory command

Full Usage: Command.currentDir directory command

Parameters:
    directory : string
    command : Command

Returns: Command

Set the working directory for the run.

directory : string
command : Command
Returns: Command

Command.encoding enc command

Full Usage: Command.encoding enc command

Parameters:
Returns: Command

Decode both captured streams with `encoding`.

enc : Encoding
command : Command
Returns: Command

Command.env key value command

Full Usage: Command.env key value command

Parameters:
    key : string
    value : string
    command : Command

Returns: Command

Set an environment variable for the child.

key : string
value : string
command : Command
Returns: Command

Command.envClear command

Full Usage: Command.envClear command

Parameters:
Returns: Command

Start the child's environment empty instead of inheriting the parent's.

command : Command
Returns: Command

Command.envRemove key command

Full Usage: Command.envRemove key command

Parameters:
Returns: Command

Remove an inherited environment variable from the child.

key : string
command : Command
Returns: Command

Command.gid value command

Full Usage: Command.gid value command

Parameters:
Returns: Command

Run the child under this Unix group id (`setgid`). Unix-only, same notes as `uid`. See `Command.Gid`.

value : int
command : Command
Returns: Command

Command.groups gids command

Full Usage: Command.groups gids command

Parameters:
Returns: Command

Set the child's Unix supplementary groups, replacing the inherited set — the third leg of a privilege drop. Meaningful only alongside a `Uid`/`Gid` drop (else `ProcessError.Spawn`); Unix-only (a set value fails a Windows spawn with `ProcessError.Unsupported`). See `Command.Groups`.

gids : int seq
command : Command
Returns: Command

Command.idleTimeout duration command

Full Usage: Command.idleTimeout duration command

Parameters:
Returns: Command

Kill the run when it produces no output (stdout or stderr) for `duration` — reset by each chunk of output — independent of the total `Command.Timeout`.

duration : TimeSpan
command : Command
Returns: Command

Command.inheritStdin command

Full Usage: Command.inheritStdin command

Parameters:
Returns: Command

Hand the child the parent process's own standard input directly (inherited, no pipe/feeder), for interactive/console programs. See `Command.InheritStdin`.

command : Command
Returns: Command

Command.keepStdinOpen command

Full Usage: Command.keepStdinOpen command

Parameters:
Returns: Command

Keep the child's stdin pipe open after the source is exhausted.

command : Command
Returns: Command

Command.lineTerminator terminator command

Full Usage: Command.lineTerminator terminator command

Parameters:
Returns: Command

Frame both captured/streamed streams' lines with `terminator` (default `LineTerminator.Lf`).

terminator : LineTerminator
command : Command
Returns: Command

Command.logger logger command

Full Usage: Command.logger logger command

Parameters:
Returns: Command

Emit structured lifecycle events to `logger` (argv/env never logged).

logger : ILogger
command : Command
Returns: Command

Command.mergeStderr command

Full Usage: Command.mergeStderr command

Parameters:
Returns: Command

Merge the child's stderr into its stdout at the OS level (like a shell `2>&1`); the two streams then interleave byte-for-byte on the single stdout stream, and there is no separate stderr stream. See `Command.MergeStderr`.

command : Command
Returns: Command

Command.okCodes codes command

Full Usage: Command.okCodes codes command

Parameters:
    codes : int seq
    command : Command

Returns: Command

Replace the success exit-code set with these codes (default `{0}`; include `0` to keep it; an empty set is a no-op that keeps the previously configured codes).

codes : int seq
command : Command
Returns: Command

Command.onStderrLine handler command

Full Usage: Command.onStderrLine handler command

Parameters:
    handler : string -> unit
    command : Command

Returns: Command

Invoke `handler` for each captured stderr line.

handler : string -> unit
command : Command
Returns: Command

Command.onStdoutLine handler command

Full Usage: Command.onStdoutLine handler command

Parameters:
    handler : string -> unit
    command : Command

Returns: Command

Invoke `handler` for each captured stdout line.

handler : string -> unit
command : Command
Returns: Command

Command.outputBuffer policy command

Full Usage: Command.outputBuffer policy command

Parameters:
Returns: Command

Bound the in-memory backlog of captured lines.

policy : OutputBufferPolicy
command : Command
Returns: Command

Command.priority level command

Full Usage: Command.priority level command

Parameters:
Returns: Command

Launch the child (and its spawned tree) at a lower/higher CPU-scheduling priority (Windows priority class / Unix nice). Supported on both platforms; the default leaves the OS default.

level : Priority
command : Command
Returns: Command

Command.retry maxAttempts delay shouldRetry command

Full Usage: Command.retry maxAttempts delay shouldRetry command

Parameters:
Returns: Command

Run the command up to `maxAttempts` times in total (initial run plus retries), waiting `delay` between attempts (`0`/`1` both mean a single run).

maxAttempts : int
delay : TimeSpan
shouldRetry : ProcessError -> bool
command : Command
Returns: Command

Command.retryNever command

Full Usage: Command.retryNever command

Parameters:
Returns: Command

Explicitly disable retrying for this command, overriding any inherited `Retry` policy (e.g. from a `CliClient.WithDefaults` template). The command always runs exactly once.

command : Command
Returns: Command

Command.setsid command

Full Usage: Command.setsid command

Parameters:
Returns: Command

Detach the child into a new session (`setsid()`). Unix-only: a set request fails a Windows spawn with `ProcessError.Unsupported`. Containment is preserved. See `Command.Setsid`.

command : Command
Returns: Command

Command.stderr mode command

Full Usage: Command.stderr mode command

Parameters:
Returns: Command

Set how the child's standard error is connected.

mode : StdioMode
command : Command
Returns: Command

Command.stderrEncoding enc command

Full Usage: Command.stderrEncoding enc command

Parameters:
Returns: Command

Decode captured stderr with `encoding`.

enc : Encoding
command : Command
Returns: Command

Command.stderrLineTerminator terminator command

Full Usage: Command.stderrLineTerminator terminator command

Parameters:
Returns: Command

Frame captured/streamed stderr lines with `terminator` (default `LineTerminator.Lf`).

terminator : LineTerminator
command : Command
Returns: Command

Command.stderrTee sink command

Full Usage: Command.stderrTee sink command

Parameters:
Returns: Command

Copy raw captured stderr bytes to `sink`.

sink : Stream
command : Command
Returns: Command

Command.stdin source command

Full Usage: Command.stdin source command

Parameters:
Returns: Command

Feed the child's standard input from `source`.

source : Stdin
command : Command
Returns: Command

Command.stdout mode command

Full Usage: Command.stdout mode command

Parameters:
Returns: Command

Set how the child's standard output is connected.

mode : StdioMode
command : Command
Returns: Command

Command.stdoutEncoding enc command

Full Usage: Command.stdoutEncoding enc command

Parameters:
Returns: Command

Decode captured stdout with `encoding`.

enc : Encoding
command : Command
Returns: Command

Command.stdoutLineTerminator terminator command

Full Usage: Command.stdoutLineTerminator terminator command

Parameters:
Returns: Command

Frame captured/streamed stdout lines with `terminator` (default `LineTerminator.Lf`).

terminator : LineTerminator
command : Command
Returns: Command

Command.stdoutTee sink command

Full Usage: Command.stdoutTee sink command

Parameters:
Returns: Command

Copy raw captured stdout bytes to `sink`.

sink : Stream
command : Command
Returns: Command

Command.streamBuffer policy command

Full Usage: Command.streamBuffer policy command

Parameters:
Returns: Command

Opt in to a bounded/backpressure channel for the streaming verbs (default stays unbounded).

policy : StreamBufferPolicy
command : Command
Returns: Command

Command.timeout duration command

Full Usage: Command.timeout duration command

Parameters:
Returns: Command

Kill the run after `duration`.

duration : TimeSpan
command : Command
Returns: Command

Command.timeoutGrace grace command

Full Usage: Command.timeoutGrace grace command

Parameters:
Returns: Command

Terminate gracefully on timeout, force-killing only after `grace`.

grace : TimeSpan
command : Command
Returns: Command

Command.uid value command

Full Usage: Command.uid value command

Parameters:
Returns: Command

Run the child under this Unix user id (`setuid`). Unix-only: a set uid fails a Windows spawn with `ProcessError.Unsupported`; dropping needs privilege (else `ProcessError.Spawn`). See `Command.Uid`.

value : int
command : Command
Returns: Command

Command.umask mask command

Full Usage: Command.umask mask command

Parameters:
Returns: Command

Set the child's Unix file-mode creation mask (`umask(2)`). Unix-only: a set mask fails a Windows spawn with `ProcessError.Unsupported`. The default leaves the inherited umask untouched.

mask : int
command : Command
Returns: Command

Command.uncheckedInPipe command

Full Usage: Command.uncheckedInPipe command

Parameters:
Returns: Command

Inside a pipeline, allow this stage to exit non-zero without failing the pipeline.

command : Command
Returns: Command

Command.user uid gid command

Full Usage: Command.user uid gid command

Parameters:
    uid : int
    gid : int
    command : Command

Returns: Command

Run the child under this Unix user and group id (the privilege-drop pair). See `Command.User`.

uid : int
gid : int
command : Command
Returns: Command

Command.windowsCtrlSignals command

Full Usage: Command.windowsCtrlSignals command

Parameters:
Returns: Command

Windows: spawn the child as its own console process group so `ProcessGroup.Signal(Signal.Int/Term)` can deliver a best-effort CTRL+BREAK (no effect on Unix). See `Command.WindowsCtrlSignals`.

command : Command
Returns: Command

Type something to start searching.