Cmd

Struct Cmd 

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

A command.

Implementations§

Source§

impl Cmd

Source

pub fn new(program: impl AsRef<Path>) -> Cmd

Creates a new Cmd that executes the given program.

Source

pub fn arg(self, arg: impl AsRef<OsStr>) -> Cmd

Pushes an argument onto this Cmd.

Source

pub fn args<I>(self, args: I) -> Cmd

Pushes the arguments onto this Cmd.

Source

pub fn ignore_status(self) -> Cmd

Returns a Cmd that ignores its exit status.

Source

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

Returns a Cmd with the given stdin.

Source

pub fn echo_cmd(self, echo: bool) -> Cmd

Returns a Cmd that echoes itself (or not) as specified.

Source

pub fn secret(self, secret: bool) -> Cmd

Returns a Cmd that is secret (or not) as specified.

If a command is secret, it echoes <secret> instead of the program and its arguments.

Source

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

Returns the stdout from running the command.

Source

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

Returns the stderr from running the command.

Source

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

Returns a std::process::Output from running the command.

Source

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

Runs the command.

Examples found in repository?
examples/ci.rs (line 17)
12fn try_main() -> Result<()> {
13    let cargo_toml = cargo_toml()?;
14
15    {
16        let _s = section("BUILD");
17        cmd!("cargo test --workspace --no-run").run()?;
18    }
19
20    {
21        let _s = section("TEST");
22        cmd!("cargo test --workspace --no-run").run()?;
23    }
24
25    let version = cargo_toml.version()?;
26    let tag = format!("v{}", version);
27    let dry_run = env::var("CI").is_err()
28        || git::tag_list()?.contains(&tag)
29        || git::current_branch()? != "master";
30    xaction::set_dry_run(dry_run);
31
32    {
33        let _s = section("PUBLISH");
34        cargo_toml.publish()?;
35        git::tag(&tag)?;
36        git::push_tags()?;
37    }
38    Ok(())
39}

Trait Implementations§

Source§

impl Debug for Cmd

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Cmd

Source§

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

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> 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.