Struct clonable_command::Command 
source · pub struct Command {
    pub name: OsString,
    pub arguments: Vec<OsString>,
    pub inherit_environment: bool,
    pub environment: HashMap<OsString, Option<OsString>>,
    pub current_dir: Option<PathBuf>,
    pub stdin: Option<Stdio>,
    pub stdout: Option<Stdio>,
    pub stderr: Option<Stdio>,
}Expand description
A process builder, providing fine-grained control over how a new process should be spawned. Equivalent to std’s Command but allowing field access cloning and serialization.
Fields§
§name: OsStringName of the program invoked.
arguments: Vec<OsString>Arguments passed to the child process.
inherit_environment: boolControlls whether the child process will inherit the parent process’ environment.
environment: HashMap<OsString, Option<OsString>>Environment for the child process, None represents variables that will
not be inherited from the parent, even when inherit_environment == true.
current_dir: Option<PathBuf>Working directory for the child process.
stdin: Option<Stdio>Child process’ standard input (stdin) handle, None will use default
for invocation type.
stdout: Option<Stdio>Child process’ standard output (stdout) handle, None will use default
for invocation type.
stderr: Option<Stdio>Child process’ standard error (stderr) handle, None will use default
for invocation type.
Implementations§
source§impl Command
 
impl Command
Builder
sourcepub fn args(self, args: impl IntoIterator<Item = impl AsRef<OsStr>>) -> Self
 
pub fn args(self, args: impl IntoIterator<Item = impl AsRef<OsStr>>) -> Self
Adds multiple arguments to pass to the program. more
sourcepub fn env(self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>) -> Self
 
pub fn env(self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>) -> Self
Inserts or updates an environment variable. more
sourcepub fn envs(
    self,
    vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>
) -> Self
 
pub fn envs( self, vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)> ) -> Self
Inserts or updates multiple environment variables. more
sourcepub fn env_remove(self, key: impl AsRef<OsStr>) -> Self
 
pub fn env_remove(self, key: impl AsRef<OsStr>) -> Self
Removes an explicitly set environment variable and prevents inheriting it from a parent process. more
sourcepub fn env_clear(self) -> Self
 
pub fn env_clear(self) -> Self
Clears all explicitly set environment variables and prevents inheriting any parent process environment variables. more
sourcepub fn env_no_inherit(self) -> Self
 
pub fn env_no_inherit(self) -> Self
Prevents inheriting any parent process environment variables (like
env_clear without clearing set envs).
sourcepub fn current_dir(self, key: impl AsRef<Path>) -> Self
 
pub fn current_dir(self, key: impl AsRef<Path>) -> Self
Sets the working directory for the child process. more
sourcepub fn stdin(self, stdin: Stdio) -> Self
 
pub fn stdin(self, stdin: Stdio) -> Self
Configuration for the child process’s standard input (stdin) handle. more
source§impl Command
 
impl Command
Setters
sourcepub fn add_arg(&mut self, arg: impl AsRef<OsStr>)
 
pub fn add_arg(&mut self, arg: impl AsRef<OsStr>)
Adds an argument to pass to the program. more
sourcepub fn add_args(&mut self, args: impl IntoIterator<Item = impl AsRef<OsStr>>)
 
pub fn add_args(&mut self, args: impl IntoIterator<Item = impl AsRef<OsStr>>)
Adds multiple arguments to pass to the program. more
sourcepub fn set_env(&mut self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>)
 
pub fn set_env(&mut self, key: impl AsRef<OsStr>, val: impl AsRef<OsStr>)
Inserts or updates an environment variable. more
sourcepub fn set_envs(
    &mut self,
    vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>
)
 
pub fn set_envs( &mut self, vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)> )
Inserts or updates multiple environment variables. more
sourcepub fn remove_env(&mut self, key: impl AsRef<OsStr>)
 
pub fn remove_env(&mut self, key: impl AsRef<OsStr>)
Removes an explicitly set environment variable and prevents inheriting it from a parent process. more
sourcepub fn set_current_dir(&mut self, path: impl AsRef<Path>)
 
pub fn set_current_dir(&mut self, path: impl AsRef<Path>)
Sets the working directory for the child process. more
source§impl Command
 
impl Command
Execution
sourcepub fn spawn(&self) -> Result<Child>
 
pub fn spawn(&self) -> Result<Child>
Behaves identical to std’s Command::spawn.
sourcepub fn output(&self) -> Result<Output>
 
pub fn output(&self) -> Result<Output>
Behaves identical to std’s Command::output.
sourcepub fn status(&self) -> Result<ExitStatus>
 
pub fn status(&self) -> Result<ExitStatus>
Behaves identical to std’s Command::status.