Module command

Source
Expand description

A more convenient interface than std::process::* for running external programs.

Structs§

Capturing
Which outputs and how they should be captured. Can’t clone, the contained handles are not clonable; use available before consuming this if you need to retain the knowledge about available captures.
Outputs
Wrapper around Output that dereferences to it, but also offers a truthy field, and implements Display to show a multi-line message with both process status and its outputs.

Enums§

AvailableCaptures

Functions§

command_with_settings
run
Run cmd with arguments and the env overridden with the key-value pairs in set_env, wait for its completion. Returns an error if cmd exited with a code that is not in acceptable_status_codes. Returns true when 0 is in acceptable_status_codes and cmd exited with status 0, false for other accepted status codes. silencing specifies captures that should be done, which are dropped unless there’s an error.
run_output
run_outputs
Same as run but captures outputs, returning (exited_0, stdout, stderr)
run_stderr
Same as run but captures and returns stderr.
run_stdout
Same as run but captures and returns stdout.
run_stdout_string
Same as run_stdout but returns stdout as a utf-8 decoded string.
spawn
Run cmd with arguments and the env overridden with the key-value pairs in set_env, return a Child handle (does not wait for its completion). If you don’t want to capture outputs, pass Captures::none() to captures. Note: if you just want to run a process in the background and are not actually reading from the filehandles in Child, then you definitely want to set this to Captures::none(), because otherwise the outputs will go nowhere, or even block the child process after filling the pipe buffer.