[−][src]Struct command_run::Command
A command to run in a subprocess and options for how it is run.
Some notable trait implementations:
- Derives
Clone,Debug,Eq, andPartialEq Default(see docstrings for each field for what the corresponding default is)From<&Command> for std::process::Commandto convert to astd::process::Command
Fields
program: PathBufProgram path.
The path can be just a file name, in which case the $PATH is
searched.
args: Vec<OsString>Arguments passed to the program.
dir: Option<PathBuf>Directory from which to run the program.
If not set (the default), the current working directory is used.
log_to: LogToWhere log messages go. The default is stdout.
log_command: boolIf true (the default), log the command before running it.
log_output_on_error: boolIf true, log the output if the command exits non-zero or due
to a signal. This does nothing is capture is false or if
check is false. The default is false.
check: boolIf true (the default), check if the command exited
successfully and return an error if not.
capture: boolIf true, capture the stdout and stderr of the
command. The default is false.
combine_output: boolIf true, send stderr to stdout; the stderr field in
Output will be empty. The default is false.
clear_env: boolIf false (the default), inherit environment variables from the
current process.
env: HashMap<OsString, OsString>Add or update environment variables in the child process.
Implementations
impl Command[src]
pub fn new<S: AsRef<OsStr>>(program: S) -> Command[src]
Make a new Command with the given program.
All other fields are set to the defaults.
pub fn with_args<I, S1, S2>(program: S1, args: I) -> Command where
S1: AsRef<OsStr>,
S2: AsRef<OsStr>,
I: IntoIterator<Item = S2>, [src]
S1: AsRef<OsStr>,
S2: AsRef<OsStr>,
I: IntoIterator<Item = S2>,
Make a new Command with the given program and args.
All other fields are set to the defaults.
pub fn add_arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self[src]
Append a single argument.
pub fn add_arg_pair<S1, S2>(&mut self, arg1: S1, arg2: S2) -> &mut Self where
S1: AsRef<OsStr>,
S2: AsRef<OsStr>, [src]
S1: AsRef<OsStr>,
S2: AsRef<OsStr>,
Append two arguments.
This is equivalent to calling add_arg twice; it is for the
common case where the arguments have different types, e.g. a
literal string for the first argument and a Path for the
second argument.
pub fn add_args<I, S>(&mut self, args: I) -> &mut Self where
S: AsRef<OsStr>,
I: IntoIterator<Item = S>, [src]
S: AsRef<OsStr>,
I: IntoIterator<Item = S>,
Append multiple arguments.
pub fn enable_capture(&mut self) -> &mut Self[src]
Set capture to true.
pub fn combine_output(&mut self) -> &mut Self[src]
Set combine_output to true.
pub fn set_dir<S: AsRef<OsStr>>(&mut self, dir: S) -> &mut Self[src]
Set the directory from which to run the program.
pub fn disable_check(&mut self) -> &mut Self[src]
Set check to false.
pub fn run(&self) -> Result<Output, Error>[src]
Run the command.
If capture is true, the command's output (stdout and
stderr) is returned along with the status. If not, the stdout
and stderr are empty.
If the command fails to start an error is returned. If check is set, an error is also returned if the command exits non-zero or due to a signal.
If log_command is true then the command line is logged
before running it. If the command fails the error is not
logged or printed, but the resulting error type implements
Display and can be used for this purpose.
pub fn command_line_lossy(&self) -> String[src]
Format as a space-separated command line.
The program path and the arguments are converted to strings
with String::from_utf8_lossy.
If any component contains characters that are not ASCII
alphanumeric or in the set /-,:.=, the component is
quoted with ' (single quotes). This is both too aggressive
(unnecessarily quoting things that don't need to be quoted)
and incorrect (e.g. a single quote will itself be quoted with
a single quote). This method is mostly intended for logging
though, and it should work reasonably well for that.
Trait Implementations
impl Clone for Command[src]
impl Debug for Command[src]
impl Default for Command[src]
impl Eq for Command[src]
impl<'_> From<&'_ Command> for Command[src]
impl PartialEq<Command> for Command[src]
impl StructuralEq for Command[src]
impl StructuralPartialEq for Command[src]
Auto Trait Implementations
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
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,
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> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
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.
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>,