3 releases

0.1.2 Mar 19, 2023
0.1.1 Feb 23, 2023
0.1.0 Feb 23, 2023

#1242 in Text processing

Download history 7/week @ 2024-07-29 6/week @ 2024-08-26 15/week @ 2024-09-02 26/week @ 2024-09-09 13/week @ 2024-09-16 44/week @ 2024-09-23 115/week @ 2024-09-30 71/week @ 2024-10-07 78/week @ 2024-10-14 291/week @ 2024-10-21 31/week @ 2024-10-28

472 downloads per month
Used in pr_buddy

AGPL-3.0

15KB
190 lines

shutil

Rust shell utility helper library

Installing

cargo add shutil

Using command pipelines in rust

shutil::pipe() makes it easy to execute command pipelines in rust.

For example, say you want to execute the following pipeline:

echo foo | rev | tr 'a-z' 'A-Z'

This will echo the string "foo", reverse it, and then change lowercase characters to uppercase. The result will be the string "OOF". Here is the equivalent rust code:

use shutil::pipe;

fn main() {
    // Executes `echo "foo" | rev | tr "a-z" "A-Z"`
    let output = pipe(vec![
        vec!["echo", "foo"],
        vec!["rev"],
        vec!["tr", "a-z", "A-Z"],
    ]);

    // prints "OOF"
    println!("{}", output.unwrap());
}

No runtime deps