shutil

Crates.ioshutil
lib.rsshutil
version0.1.2
sourcesrc
created_at2023-02-23 07:44:05.440805
updated_at2023-03-19 18:36:34.067562
descriptionShell utility helper library
homepagehttps://github.com/rajbot/shutil
repositoryhttps://github.com/rajbot/shutil
max_upload_size
id792392
size43,894
(rajbot)

documentation

README

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());
}
Commit count: 8

cargo fmt