[−][src]Struct bossy::Command
Build and run commands to your heart's content.
Implementations
impl Command
[src]
pub fn impure(name: impl AsRef<OsStr>) -> Self
[src]
Start building a command that inherits all env vars from the environment.
pub fn pure(name: impl AsRef<OsStr>) -> Self
[src]
Start building a command with a completely clean environment. Note that
at minimum, you'll often want to add PATH
and TERM
to the environment
for things to function as expected.
pub fn try_impure_parse(arg_str: impl AsRef<str>) -> Option<Self>
[src]
The same as impure
, but parses the command from a string of
whitespace-separated args, just like how you'd write the command in a
terminal.
pub fn impure_parse(arg_str: impl AsRef<str>) -> Self
[src]
The same as try_impure_parse
, but panics if given an empty string.
pub fn try_pure_parse(arg_str: impl AsRef<str>) -> Option<Self>
[src]
The same as pure
, but parses the command from a string of
whitespace-separated args, just like how you'd write the command in a
terminal.
pub fn pure_parse(arg_str: impl AsRef<str>) -> Self
[src]
The same as try_pure_parse
, but panics if given an empty string.
pub fn display(&self) -> &str
[src]
Get the command's string representation.
pub fn set_stdin(&mut self, cfg: impl Into<Stdio>) -> &mut Self
[src]
pub fn with_stdin(self, cfg: impl Into<Stdio>) -> Self
[src]
pub fn set_stdin_piped(&mut self) -> &mut Self
[src]
pub fn with_stdin_piped(self) -> Self
[src]
pub fn set_stdin_null(&mut self) -> &mut Self
[src]
pub fn with_stdin_null(self) -> Self
[src]
pub fn set_stdout(&mut self, cfg: impl Into<Stdio>) -> &mut Self
[src]
pub fn with_stdout(self, cfg: impl Into<Stdio>) -> Self
[src]
pub fn set_stdout_piped(&mut self) -> &mut Self
[src]
pub fn with_stdout_piped(self) -> Self
[src]
pub fn set_stdout_null(&mut self) -> &mut Self
[src]
pub fn with_stdout_null(self) -> Self
[src]
pub fn set_stderr(&mut self, cfg: impl Into<Stdio>) -> &mut Self
[src]
pub fn with_stderr(self, cfg: impl Into<Stdio>) -> Self
[src]
pub fn set_stderr_piped(&mut self) -> &mut Self
[src]
pub fn with_stderr_piped(self) -> Self
[src]
pub fn set_stderr_null(&mut self) -> &mut Self
[src]
pub fn with_stderr_null(self) -> Self
[src]
pub fn add_env_var(
&mut self,
key: impl AsRef<OsStr>,
val: impl AsRef<OsStr>
) -> &mut Self
[src]
&mut self,
key: impl AsRef<OsStr>,
val: impl AsRef<OsStr>
) -> &mut Self
pub fn with_env_var(
self,
key: impl AsRef<OsStr>,
val: impl AsRef<OsStr>
) -> Self
[src]
self,
key: impl AsRef<OsStr>,
val: impl AsRef<OsStr>
) -> Self
pub fn add_env_vars(
&mut self,
vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>
) -> &mut Self
[src]
&mut self,
vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>
) -> &mut Self
pub fn with_env_vars(
self,
vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>
) -> Self
[src]
self,
vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>
) -> Self
pub fn add_arg(&mut self, name: impl AsRef<OsStr>) -> &mut Self
[src]
pub fn with_arg(self, name: impl AsRef<OsStr>) -> Self
[src]
pub fn add_args(
&mut self,
args: impl IntoIterator<Item = impl AsRef<OsStr>>
) -> &mut Self
[src]
&mut self,
args: impl IntoIterator<Item = impl AsRef<OsStr>>
) -> &mut Self
pub fn with_args(
self,
args: impl IntoIterator<Item = impl AsRef<OsStr>>
) -> Self
[src]
self,
args: impl IntoIterator<Item = impl AsRef<OsStr>>
) -> Self
pub fn add_parsed_args(&mut self, arg_str: impl AsRef<str>) -> &mut Self
[src]
The same as add_args
, but parses the arg list from a string of
whitespace-separated args, just like how you'd see them in a terminal.
pub fn with_parsed_args(self, arg_str: impl AsRef<str>) -> Self
[src]
The same as with_args
, but parses the arg list from a string of
whitespace-separated args, just like how you'd see them in a terminal.
pub fn run(&mut self) -> Result<Handle>
[src]
Run the command and give you a delightful Handle
to it. This allows
you to decide when blocking should happen, but if you don't care, then
Command::run_and_wait
and Command::run_and_wait_for_output
are
better picks.
pub fn run_and_detach(&mut self) -> Result<()>
[src]
Run the command and then detach it from the parent process. This allows
the child process to outlive the parent process, akin to what can be
achieved using nohup
or setsid
. This will automatically set stdin,
stdout, and stderr to use Stdio::null
, so if you don't want that to
happen, then you're screwed.
pub fn run_and_wait(&mut self) -> Result<ExitStatus>
[src]
Run the command and block until it exits.
pub fn run_and_wait_for_output(&mut self) -> Result<Output>
[src]
Run the command and block until its output is collected. This will
automatically set stdout and stderr to use Stdio::piped
, so if you
don't want that to happen, then you're screwed.
pub fn run_and_wait_for_str<T>(
&mut self,
f: impl FnOnce(&str) -> T
) -> Result<T>
[src]
&mut self,
f: impl FnOnce(&str) -> T
) -> Result<T>
pub fn run_and_wait_for_string(&mut self) -> Result<String>
[src]
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Command
[src]
impl Send for Command
[src]
impl Sync for Command
[src]
impl Unpin for Command
[src]
impl UnwindSafe for Command
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,