cmd_lib - Rust command line library
Common rust command line macros and utils, to write shell script like tasks easily in rust programming language.
run_cmd! --> CmdResult
let name = "rust";
run_cmd!("echo hello, {}", name);
// pipe commands are also supported
run_cmd!("du -ah . | sort -hr | head -n 10");
run_fun! --> FunResult
let version = run_fun!("rustc --version")?;
info!("Your rust version is {}", version.trim());
// with pipes
let n = run_fun!("echo the quick brown fox jumped over the lazy dog | wc -w")?;
info!("There are {} words in above sentence", n.trim());
Complete example
use ;
output:
)
Related
See rust-shell-script, which can compile rust-shell-script scripting language directly into rust code.