pub struct Cmd { /* private fields */ }Expand description
A command.
Implementations§
Source§impl Cmd
impl Cmd
Sourcepub fn new(program: impl AsRef<Path>) -> Cmd
pub fn new(program: impl AsRef<Path>) -> Cmd
Creates a new Cmd that executes the given program.
Sourcepub fn ignore_status(self) -> Cmd
pub fn ignore_status(self) -> Cmd
Returns a Cmd that ignores its exit status.
Sourcepub fn echo_cmd(self, echo: bool) -> Cmd
pub fn echo_cmd(self, echo: bool) -> Cmd
Returns a Cmd that echoes itself (or not) as specified.
Sourcepub fn secret(self, secret: bool) -> Cmd
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.
Sourcepub fn read_stderr(self) -> Result<String, Error>
pub fn read_stderr(self) -> Result<String, Error>
Returns the stderr from running the command.
Sourcepub fn output(self) -> Result<Output, Error>
pub fn output(self) -> Result<Output, Error>
Returns a std::process::Output from running the command.
Sourcepub fn run(self) -> Result<(), Error>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more