pub struct CommandBuilder { /* private fields */ }Expand description
Command builder for asynchronous execution.
Implementations§
Source§impl CommandBuilder
impl CommandBuilder
Sourcepub fn new<S: AsRef<OsStr>>(program: S) -> Self
pub fn new<S: AsRef<OsStr>>(program: S) -> Self
Creates a new command builder for the specified program.
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_clear(self) -> Self
pub fn env_clear(self) -> Self
Clears all environment variables inherited from the parent process.
Sourcepub fn env_remove<K>(self, key: K) -> Self
pub fn env_remove<K>(self, key: K) -> Self
Removes an environment variable from the command’s environment.
Sourcepub fn current_dir<D>(self, dir: D) -> Self
pub fn current_dir<D>(self, dir: D) -> Self
Sets the working directory for the command.
Sourcepub fn stdin<T: Into<Stdio>>(self, stdin: T) -> Self
pub fn stdin<T: Into<Stdio>>(self, stdin: T) -> Self
Configures the stdin handle for the command.
Sourcepub fn stdout<T: Into<Stdio>>(self, stdout: T) -> Self
pub fn stdout<T: Into<Stdio>>(self, stdout: T) -> Self
Configures the stdout handle for the command.
Sourcepub fn stderr<T: Into<Stdio>>(self, stderr: T) -> Self
pub fn stderr<T: Into<Stdio>>(self, stderr: T) -> Self
Configures the stderr handle for the command.
Sourcepub fn capture_output(self) -> Self
pub fn capture_output(self) -> Self
Configures the command to capture both stdout and stderr.
Sourcepub fn inherit_stdin(self) -> Self
pub fn inherit_stdin(self) -> Self
Configures the command to inherit stdin from the parent process.
Sourcepub fn inherit_stdout(self) -> Self
pub fn inherit_stdout(self) -> Self
Configures the command to inherit stdout from the parent process.
Sourcepub fn inherit_stderr(self) -> Self
pub fn inherit_stderr(self) -> Self
Configures the command to inherit stderr from the parent process.
Sourcepub fn null_stdin(self) -> Self
pub fn null_stdin(self) -> Self
Configures the command to read from null stdin.
Sourcepub fn null_stdout(self) -> Self
pub fn null_stdout(self) -> Self
Configures the command to write to null stdout.
Sourcepub fn null_stderr(self) -> Self
pub fn null_stderr(self) -> Self
Configures the command to write to null stderr.
Sourcepub fn kill_on_drop(self, kill: bool) -> Self
pub fn kill_on_drop(self, kill: bool) -> Self
Sets whether to kill the child process when the handle is dropped.
Sourcepub async fn execute(&mut self) -> ScriptResult<Output>
pub async fn execute(&mut self) -> ScriptResult<Output>
Executes the command and captures its output, returning a ScriptResult.
Sourcepub async fn execute_with_timeout(
self,
timeout: Duration,
) -> ScriptResult<Output>
pub async fn execute_with_timeout( self, timeout: Duration, ) -> ScriptResult<Output>
Executes the command with a timeout.
Sourcepub async fn status(&mut self) -> Result<ExitStatus>
pub async fn status(&mut self) -> Result<ExitStatus>
Waits for the command to complete and returns its exit status.