Struct bigbro::Status [] [src]

pub struct Status { /* fields omitted */ }

The result of running a command using bigbro.

It contains the ExitStatus as well as the information about files and directories accessed by the command.

Methods

impl Status
[src]

This returns the std::process::ExitStatus of the process. Was termination successful? Signal termination not considered a success, and success is defined as a zero exit status.

Examples

use bigbro::Command;

let status = Command::new("sh")
                     .arg("-c")
                     .arg("false")
                     .status()
                     .expect("failed to execute sh");

assert!(! status.status().success() ); // should fail because "false" always fails

This retuns the set of directories that the process read from. For details of what is meant by a process having "read from a directory", see semantics.

Examples

use bigbro::Command;

let dir = std::path::PathBuf::from("/tmp");
let status = Command::new("ls")
                     .arg(&dir)
                     .status()
                     .expect("failed to execute ls");

assert!(status.status().success() );
assert!(status.read_from_directories().contains(&dir) );

This retuns the set of files that the process read. For details of what is meant by a process having "read from a directory", see semantics.

Examples

use bigbro::Command;

let e = std::ffi::OsString::from("/usr/bin/python");
let p = std::path::PathBuf::from("/usr/bin/python");
let status = Command::new("sha1sum")
                     .arg(&e)
                     .status()
                     .expect("failed to execute sha1sum");

assert!(status.status().success() );
for f in status.read_from_files() {
   println!("read file {:#?}", f);
}
assert!(status.read_from_files().contains(&p) );

This retuns the set of files that the process wrote to. For details of what is meant by a process having "read from a directory", see semantics.

Examples

use bigbro::Command;

let p = std::path::PathBuf::from("/tmp/hello");
let status = Command::new("sh")
                     .args(&["-c", "echo hello > /tmp/hello"])
                     .status()
                     .expect("failed to execute sh");

assert!(status.status().success() );
for f in status.written_to_files() {
   println!("wrote file {:#?}", f);
}
assert!(status.written_to_files().contains(&p) );
assert!(status.written_to_files().len() == 1 );

This retuns the set of directories that the process created. For details of what is meant by a process having "read from a directory", see semantics.

This retuns the stdout, if it has been saved using save_stdouterr.

Examples

use bigbro::Command;

let mut status = Command::new("ls")
                         .arg("-l")
                         .save_stdouterr()
                         .status()
                         .expect("failed to execute ls");

assert!(status.status().success() );
let f = status.stdout().unwrap();
assert!(f.is_some());
let mut contents = String::new();
f.unwrap().read_to_string(&mut contents);
println!("ls gives: {}", contents);
assert!(contents.contains("Cargo.toml"));
assert!(contents.contains("src"));

Trait Implementations

impl Debug for Status
[src]

Formats the value using the given formatter.