an exec_cmdline function which suppresses all output

This commit is contained in:
Bruce Leidl 2019-01-03 10:49:42 -05:00
parent 140257208a
commit 9f6ba7e619

View File

@ -27,6 +27,18 @@ pub fn exec_cmdline<S: AsRef<str>>(cmd_path: &str, args: S) -> Result<()> {
check_cmd_status(cmd_path, &status) check_cmd_status(cmd_path, &status)
} }
pub fn exec_cmdline_quiet<S: AsRef<str>>(cmd_path: &str, args: S) -> Result<()> {
ensure_command_exists(cmd_path)?;
let args: Vec<&str> = args.as_ref().split_whitespace().collect::<Vec<_>>();
let status = Command::new(cmd_path)
.args(args)
.stderr(Stdio::null())
.stdout(Stdio::null())
.status()?;
check_cmd_status(cmd_path, &status)
}
pub fn exec_cmdline_with_output<S: AsRef<str>>(cmd_path: &str, args: S) -> Result<String> { pub fn exec_cmdline_with_output<S: AsRef<str>>(cmd_path: &str, args: S) -> Result<String> {
ensure_command_exists(cmd_path)?; ensure_command_exists(cmd_path)?;
let args: Vec<&str> = args.as_ref().split_whitespace().collect::<Vec<_>>(); let args: Vec<&str> = args.as_ref().split_whitespace().collect::<Vec<_>>();