mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
feat: regex for commands
This commit is contained in:
parent
b0db0447b9
commit
2f3ba438ea
3 changed files with 46 additions and 17 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue