8 releases (4 breaking)

0.13.0 Sep 8, 2020
0.12.3 Sep 6, 2020
0.11.0 Sep 5, 2020
0.10.0 Sep 5, 2020
0.9.0 Sep 5, 2020

#59 in Operating systems

Download history 201/week @ 2020-09-03 116/week @ 2020-09-10 105/week @ 2020-09-17

140 downloads per month
Used in 3 crates (via docker-command)

Apache-2.0

16KB
284 lines

command-run

crates.io Documentation

Rust library for running a command in a subprocess.

This library is a thin wrapper around the std::process::Command type with a few additional convenient features:

  • Print or log the command before running it
  • Optionally return an error if the command is not successful
  • Optionally combine stdout and stderr
  • Optionally print the command's output if the command fails
  • The command can be formatted as a command-line string
  • The Command type can be cloned and its fields are public

Dependencies and features

  • log - this is an optional dependency. It can be disabled by turning off the logging feature:

    command-run = { version = "*", default-features = false }
    
  • os_pipe - this dependency is used to implement combine_output.

Example

// This will return an error if the command did not exit successfully
// (controlled with the `check` field).
let output = Command::with_args("echo", &["hello", "world"])
    .enable_capture()
    .run()?;
assert_eq!(output.stdout_string_lossy(), "hello world\n");

Dependencies

~76KB