Struct Cmd

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

Clone-able variant of std::process::Command with some build specific helper methods

Cloning allows configuring commands with some common arguments and then invoking it with additional arguments/env vars at different places inside the script.

Method of this type are mirroring those of std::process::Command with addition of run and run_result commands for easier use inside of build sript.

Implementations§

Source§

impl Cmd

Source

pub fn new<S: AsRef<OsStr>>(program: S) -> Self

Constructs a new Cmd for launching the executable at path program

Source

pub fn arg<S: AsRef<OsStr>>(self, arg: S) -> Self

Adds an argument to the list of execution arguments

Source

pub fn args<I, S>(self, args: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Adds multiple arguments to the list of execution arguments

Source

pub fn env<K: AsRef<OsStr>, V: AsRef<OsStr>>(self, env: K, val: V) -> Self

Sets an environment variable

Source

pub fn output(&self) -> Output

Run the command and return it’s output.

This is convienece method for calling std::process::Command::output() method on command instance retrieved by command method

Source

pub fn run(&self)

Run the command and exit the build with informative panic message if execution fails.

This is convienece method for calling std::process::Command::status() method on command instance retrieved by command method

Source

pub fn run_result(&self) -> Result<ExitStatus>

Run the command and return it’s status.

This is convienece method for calling std::process::Command::status() method on command instance retrieved by command method

Source

pub fn command(&self) -> Command

Build the std::process::Command with args and environment variables set up by methods on this Cmd instance.

Trait Implementations§

Source§

impl Clone for Cmd

Source§

fn clone(&self) -> Cmd

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cmd

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Cmd

§

impl RefUnwindSafe for Cmd

§

impl Send for Cmd

§

impl Sync for Cmd

§

impl Unpin for Cmd

§

impl UnwindSafe for Cmd

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.