Thanks to the better stable proc-macro ecosystem and std::process APIs, I can make several improvements for this rust_cmd_lib library:
- automatic variable substitution:
let msg = "I love rust";
run_cmd!(echo "This is the message: $msg")?;
run_cmd!(du -ah . | sort -hr | head -n 10)?;
- custom command registration:
#[export_cmd(my_cmd)]
fn foo(args: CmdArgs, _envs: CmdEnvs) -> FunResult {
println!("msg from foo(), args: {:?}", args);
Ok("bar".into())
}
// to use it
use_cmd!(my_cmd);
run_cmd!(my_cmd)?;
- bunch of code clean up
Any feedback is very welcome!