FloweyCmd

Struct FloweyCmd 

pub struct FloweyCmd<'a> { /* private fields */ }
Expand description

A wrapper around [xshell::Cmd] that applies a CommandWrapperKind at execution time.

Builder methods (.arg(), .env(), etc.) are accumulated on the inner [xshell::Cmd] (for args) or in shadow fields (for env, stdin, and flags). Execution methods (.run(), .read(), etc.) consume self, apply the wrapper transformation, re-apply the shadowed state, and then execute.

Implementations§

§

impl<'a> FloweyCmd<'a>

pub fn arg<P>(self, arg: P) -> FloweyCmd<'a>
where P: AsRef<OsStr>,

Adds an argument to this command.

pub fn args<I>(self, args: I) -> FloweyCmd<'a>

Adds all of the arguments to this command.

pub fn env<K, V>(self, key: K, val: V) -> FloweyCmd<'a>
where K: AsRef<OsStr>, V: AsRef<OsStr>,

Overrides the value of an environmental variable for this command.

pub fn envs<I, K, V>(self, vars: I) -> FloweyCmd<'a>
where I: IntoIterator<Item = (K, V)>, K: AsRef<OsStr>, V: AsRef<OsStr>,

Overrides the values of specified environmental variables for this command.

pub fn env_remove<K>(self, key: K) -> FloweyCmd<'a>
where K: AsRef<OsStr>,

Removes an environment variable from this command.

pub fn env_clear(self) -> FloweyCmd<'a>

Removes all environment variables from this command.

pub fn ignore_status(self) -> FloweyCmd<'a>

If set, the command’s status code will not be checked, and non-zero exit codes will not produce an error.

pub fn set_ignore_status(&mut self, yes: bool)

Mutating variant of ignore_status.

pub fn quiet(self) -> FloweyCmd<'a>

If set, the command’s output will not be echoed to stdout.

pub fn set_quiet(&mut self, yes: bool)

Mutating variant of quiet.

pub fn secret(self) -> FloweyCmd<'a>

If set, the command is treated as containing a secret and its display will be redacted.

pub fn set_secret(&mut self, yes: bool)

Mutating variant of secret.

pub fn stdin(self, stdin: impl AsRef<[u8]>) -> FloweyCmd<'a>

Passes data to the command’s stdin.

pub fn ignore_stdout(self) -> FloweyCmd<'a>

If set, stdout is not captured.

pub fn set_ignore_stdout(&mut self, yes: bool)

Mutating variant of ignore_stdout.

pub fn ignore_stderr(self) -> FloweyCmd<'a>

If set, stderr is not captured.

pub fn set_ignore_stderr(&mut self, yes: bool)

Mutating variant of ignore_stderr.

pub fn run(self) -> Result<(), Error>

Run the command.

pub fn read(self) -> Result<String, Error>

Run the command and return its stdout as a string, with leading and trailing whitespace trimmed.

pub fn read_stderr(self) -> Result<String, Error>

Run the command and return its stderr as a string, with leading and trailing whitespace trimmed.

pub fn output(self) -> Result<Output, Error>

Run the command and return its full output.

Trait Implementations§

§

impl Display for FloweyCmd<'_>

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for FloweyCmd<'a>

§

impl<'a> RefUnwindSafe for FloweyCmd<'a>

§

impl<'a> !Send for FloweyCmd<'a>

§

impl<'a> !Sync for FloweyCmd<'a>

§

impl<'a> Unpin for FloweyCmd<'a>

§

impl<'a> UnwindSafe for FloweyCmd<'a>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.