#command #run #cmd #subprocess #process

command-run

Library for running a command in a subprocess

14 releases (6 stable)

Uses new Rust 2021

1.1.1 Nov 9, 2021
1.1.0 Nov 8, 2021
1.0.2 Aug 29, 2021
0.13.0 Sep 8, 2020
0.9.0 Sep 5, 2020

#5 in #cmd

Download history 78/week @ 2022-08-15 122/week @ 2022-08-22 82/week @ 2022-08-29 140/week @ 2022-09-05 127/week @ 2022-09-12 96/week @ 2022-09-19 39/week @ 2022-09-26 74/week @ 2022-10-03 30/week @ 2022-10-10 27/week @ 2022-10-17 95/week @ 2022-10-24 121/week @ 2022-10-31 89/week @ 2022-11-07 64/week @ 2022-11-14 82/week @ 2022-11-21 49/week @ 2022-11-28

319 downloads per month
Used in 4 crates (2 directly)

Apache-2.0

17KB
290 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

~82KB