CommandExt

Struct CommandExt 

Source
pub struct CommandExt { /* private fields */ }
Expand description

Extends std::io::process::Command.

Implementations§

Source§

impl CommandExt

Source

pub fn new(cmd: &str) -> CommandExt

Create a new CommandExt.

§Arguments
  • cmd - The command to use, i.e. “echo”.
  • exec - The Executable to use when executing the command.
Source

pub fn wd(&mut self, wd: &Path) -> &mut CommandExt

Set the working directory for the command.

§Arguments
  • wd - The working directory for the command execution.
Source

pub fn header(&mut self, show_header: bool) -> &mut CommandExt

Set the header boolean.

§Arguments
  • show_header - true, a header showing what will be executed is printed on stdout. Otherwise, no header is printed.
Source

pub fn arg(&mut self, arg: &str) -> &mut CommandExt

Add an argument to the command.

§Arguments
  • arg - The argument to add to the command.
Source

pub fn args(&mut self, args: &[&str]) -> &mut CommandExt

Add arguments to the command.

§Arguments
  • args - A vector of argments to add to the command.
Source

pub fn env(&mut self, key: &str, val: &str) -> &mut CommandExt

Set the command environment.

§Arguments
  • key - The key for the variable.
  • value - The value for the variable.
Source

pub fn exec<T>(&mut self, execfn: fn(cmd: &mut Command) -> T) -> T

Execute the Command, returning result ‘T’

§Arguments
  • execfn - A closure taking a Command, executes it via output or spawn and returns result type T.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.