shellfn 0.2.0

Attribute-like proc macro which reduces the amount of code required to call shell commands and parse the results
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use shellfn::shell;
use std::error::Error;

#[shell]
fn list_modified(dir: &str) -> Result<impl Iterator<Item = String>, Box<dyn Error>> {
    r#"
    cd $DIR
    git status | grep '^\s*modified:' | awk '{print $2}'
    "#
}

fn main() -> Result<(), Box<dyn Error>> {
    for modified in list_modified(".")? {
        println!("You have modified the file: {}", modified);
    }
    Ok(())
}