mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
fix: runtime rules without conditionals
This commit is contained in:
parent
86946a8fec
commit
b3f963738b
2 changed files with 12 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pay-respects"
|
name = "pay-respects"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# for crates.io
|
# for crates.io
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ pub fn runtime_match(
|
||||||
let rule_dir = format!("{}/pay-respects/rules", xdg_config_home);
|
let rule_dir = format!("{}/pay-respects/rules", xdg_config_home);
|
||||||
|
|
||||||
let file = format!("{}/{}.toml", rule_dir, executable);
|
let file = format!("{}/{}.toml", rule_dir, executable);
|
||||||
|
|
||||||
if !std::path::Path::new(&file).exists() {
|
if !std::path::Path::new(&file).exists() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +32,8 @@ pub fn runtime_match(
|
||||||
let rule: Rule = toml::from_str(&file).unwrap();
|
let rule: Rule = toml::from_str(&file).unwrap();
|
||||||
let split_command = split_command(&last_command);
|
let split_command = split_command(&last_command);
|
||||||
|
|
||||||
|
let mut pure_suggest;
|
||||||
|
|
||||||
for match_err in rule.match_err {
|
for match_err in rule.match_err {
|
||||||
for pattern in match_err.pattern {
|
for pattern in match_err.pattern {
|
||||||
if error_msg.contains(&pattern) {
|
if error_msg.contains(&pattern) {
|
||||||
|
|
@ -75,14 +78,15 @@ pub fn runtime_match(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// replacing placeholders
|
pure_suggest = lines.join("\n").to_owned();
|
||||||
let mut suggest = lines.join("\n").to_owned();
|
} else {
|
||||||
if suggest.contains("{{command}}") {
|
pure_suggest = suggest.to_owned();
|
||||||
suggest = suggest.replace("{{command}}", last_command);
|
|
||||||
}
|
|
||||||
eval_suggest(&suggest, last_command, error_msg, shell, &split_command);
|
|
||||||
return Some(suggest);
|
|
||||||
}
|
}
|
||||||
|
// replacing placeholders
|
||||||
|
if pure_suggest.contains("{{command}}") {
|
||||||
|
pure_suggest = pure_suggest.replace("{{command}}", last_command);
|
||||||
|
}
|
||||||
|
return eval_suggest(&pure_suggest, last_command, error_msg, shell, &split_command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue