feat: regex for commands

This commit is contained in:
iff 2023-08-07 18:34:52 +02:00
parent b0db0447b9
commit 2f3ba438ea
3 changed files with 46 additions and 17 deletions

View file

@ -67,6 +67,16 @@ fn err_regex(regex: &str, error_msg: &str) -> String {
err.join(" ")
}
fn cmd_regex(regex: &str, command: &str) -> String {
let regex = Regex::new(regex).unwrap();
let err = regex
.find_iter(command)
.map(|cap| cap.as_str().to_owned())
.collect::<Vec<String>>();
err.join(" ")
}
fn eval_shell_command(shell: &str, command: &str) -> Vec<String> {
let output = std::process::Command::new(shell)
.arg("-c")