cmd_lib 0.9.5

Common rust commandline macros and utils, to write shell script like tasks easily
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use cmd_lib::{ CmdResult, run_cmd, run_fun };

fn main() -> CmdResult {
    let red = run_fun!(tput setaf 1)?;
    let green = run_fun!(tput setaf 2)?;
    let reset = run_fun!(tput sgr0)?;
    run_cmd!(/bin/echo "1: ${red}red text ${green}green text${reset}")?;
    println!("2: \x1b[0;31mred text \x1b[0;32mgreen text\x1b[0m");
    run_cmd!(bash -c r#"echo -e "3: \x1b[0;31mred text \x1b[0;32mgreen text\x1b[0m""#)?;
    run_cmd!(bash -c "echo -e '4: \x1b[0;31mred text \x1b[0;32mgreen text\x1b[0m'")?;
    Ok(())
}