babash 0.2.0

An tiny wrapper around `std::process::Command`
Documentation
  • Coverage
  • 30%
    3 out of 10 items documented0 out of 4 items with examples
  • Size
  • Source code size: 10.07 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 306.87 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • imbolc/babash
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • imbolc

babash

An tiny wrapper around std::process::Command sacrificing performance for simplicity.

  • works on both linux and windows
  • assumes an utf-8 environment
  • logs all commands and responses with proper levels

Example

fn main() -> std::io::Result<()> {
    stderrlog::new().verbosity(4).init().unwrap();
    let r = babash::call("foo")?; // doesn't check for exit status
    assert_eq!(r.code, Some(127));
    babash::ensure_call("bar")?; // produces an error on an bad exit status
    Ok(())
}

produces the following logging output:

INFO - Calling: foo
DEBUG - Response {
    command: "foo",
    code: Some(
        127,
    ),
    success: false,
    stdout: "",
    stderr: "sh: 1: foo: not found\n",
}
INFO - Calling: bar
ERROR - Response {
    command: "bar",
    code: Some(
        127,
    ),
    success: false,
    stdout: "",
    stderr: "sh: 1: bar: not found\n",
}
Error: Custom { kind: Other, error: "Unsuccessful call: Response {\n    command: \"bar\",\n    code: Some(\n
  127,\n    ),\n    success: false,\n    stdout: \"\",\n    stderr: \"sh: 1: bar: not found\\n\",\n}" }