pub struct Cmd<'a, T: for<'enc> Utf8Encoding<'enc>> { /* private fields */ }
Expand description
A command builder.
Implementations§
Source§impl<'a, T: for<'enc> Utf8Encoding<'enc>> Cmd<'a, T>
impl<'a, T: for<'enc> Utf8Encoding<'enc>> Cmd<'a, T>
Sourcepub fn env(self, key: impl AsRef<str>, val: impl AsRef<str>) -> Self
pub fn env(self, key: impl AsRef<str>, val: impl AsRef<str>) -> Self
Sets an environment variable for the command.
Sourcepub fn envs<I, K, V>(self, vars: I) -> Self
pub fn envs<I, K, V>(self, vars: I) -> Self
Sets multiple environment variables for the command.
Sourcepub fn env_remove(self, key: impl AsRef<str>) -> Self
pub fn env_remove(self, key: impl AsRef<str>) -> Self
Removes an environment variable for the command.
Sourcepub fn ignore_status(self) -> Self
pub fn ignore_status(self) -> Self
Ignores the status of the command.
By default, the command will fail if the exit code is non-zero.
Sourcepub fn ignore_stdout(self) -> Self
pub fn ignore_stdout(self) -> Self
Ignores the stdout of the command.
By default, the command’s stdout will be captured or printed to stdout.
Sourcepub fn ignore_stderr(self) -> Self
pub fn ignore_stderr(self) -> Self
Ignores the stderr of the command.
By default, the command’s stderr will be captured or printed to stderr.
Sourcepub fn stdin(self, stdin: impl AsRef<[u8]>) -> Self
pub fn stdin(self, stdin: impl AsRef<[u8]>) -> Self
Sets contents to be written to the command’s stdin.
Sourcepub async fn run(&self) -> Result<()>
pub async fn run(&self) -> Result<()>
Runs the command and waits for it to complete.
By default, this will fail if the command’s exit code is non-zero.
By default, the command’s stdout and stderr will be captured and traced.
Sourcepub async fn read(&self) -> Result<String>
pub async fn read(&self) -> Result<String>
Runs the command and waits for it to complete, returning the stdout.
By default, this will fail if the command’s exit code is non-zero.
By default, the command’s stderr will be captured and traced.
Sourcepub async fn read_stderr(&self) -> Result<String>
pub async fn read_stderr(&self) -> Result<String>
Runs the command and waits for it to complete, returning the stderr.
By default, this will fail if the command’s exit code is non-zero.
By default, the command’s stdout will be captured and traced.