pub struct Command { /* private fields */ }Expand description
Process builder, providing fine-grained control over how a new process should be spawned.
A command is created via Container::command. This struct is similar to std::process::Command.
Implementations§
Source§impl Command
impl Command
Sourcepub fn args<I, S>(&mut self, args: I) -> &mut Self
pub fn args<I, S>(&mut self, args: I) -> &mut Self
Adds multiple arguments to pass to the program.
Sourcepub fn env(&mut self, key: &str, val: &str) -> &mut Self
pub fn env(&mut self, key: &str, val: &str) -> &mut Self
Inserts or updates an explicit environment variable mapping.
Sourcepub fn envs<I, K, V>(&mut self, vars: I) -> &mut Self
pub fn envs<I, K, V>(&mut self, vars: I) -> &mut Self
Inserts or updates multiple explicit environment variable mappings.
Sourcepub fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Self
pub fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Self
Sets the working directory for the child process.
Sourcepub fn wait_timeout(&mut self, timeout: u64) -> &mut Self
pub fn wait_timeout(&mut self, timeout: u64) -> &mut Self
Sets the number of seconds to wait for the child process to terminate.
Sourcepub fn spawn(&mut self) -> Result<Child>
pub fn spawn(&mut self) -> Result<Child>
Executes the command as a child process, returning a handle to it.
Sourcepub fn status(&mut self) -> Result<ExitStatus>
pub fn status(&mut self) -> Result<ExitStatus>
Executes a command as a child process, waiting for it to finish and collecting its status.
Sourcepub fn output(&mut self) -> Result<Output>
pub fn output(&mut self) -> Result<Output>
Executes the command as a child process, waiting for it to finish and collecting all of its output.
Sourcepub fn get_program(&self) -> &str
pub fn get_program(&self) -> &str
Returns the path to the program.
Sourcepub fn get_args(&self) -> Vec<String>
pub fn get_args(&self) -> Vec<String>
Returns the arguments that will be passed to the program.
Sourcepub fn get_envs(&self) -> HashMap<String, String>
pub fn get_envs(&self) -> HashMap<String, String>
Returns the environment variables explicitly set for the child process.
Sourcepub fn get_current_dir(&self) -> Option<&Path>
pub fn get_current_dir(&self) -> Option<&Path>
Returns the working directory for the child process.
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more