gacm_rs/shell.rs
1use std::process::{Command, Output};
2use std::str;
3
4pub fn run(command: &str, args: Vec<&str>) -> Output {
5 Command::new(command).args(args).output().unwrap()
6}
7
8pub fn run_str(command: &str, args: Vec<&str>) -> String {
9 let output = Command::new(command).args(args).output();
10
11 if let Ok(out) = output {
12 str::from_utf8(&out.stdout)
13 .unwrap()
14 .to_string()
15 .replace("\n", "")
16 } else {
17 "".to_string()
18 }
19}