Cmd Utils
rust Command
utility traits
- run command (spawn & wait wrapper)
- pipe commands
- output to file (spawn & wait & outuput to file wrapper)
CmdRun trait
use Command;
use CmdRun;
// `spawn` the command and `wait` for child process to end
// note that `run` does not return the command output, just Ok(())
// but you can redirect stdout & stderr where you want
new
// .stdout(cfg)
// .stderr(cfg)
.args
.run
.unwrap;
example available:
CmdPipe trait
use Command;
use str;
use CmdPipe;
// pipe echo & wc commands
// equivalent to bash: echo test | wc -c
let mut echo = new;
let mut wc = new;
let output = echo.arg
.pipe
.unwrap;
let res = str from_utf8.unwrap;
println!;
example available:
CmdToFile trait
use File;
use Command;
use CmdToFile;
let stdout = create.unwrap;
let stderr = create.unwrap;
let mut cmd = new;
// writes stdout to file
cmd.arg.to_file;
example available: