项目作者: nicholasbishop

项目描述 :
Rust library for running a command in a subprocess
高级语言: Rust
项目地址: git://github.com/nicholasbishop/command-run.git
创建时间: 2020-09-05T08:51:06Z
项目社区:https://github.com/nicholasbishop/command-run

开源协议:Apache License 2.0

下载


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:

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

Example

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