mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
format: remove extra spaces from error output
This commit is contained in:
parent
b16dc1dd5b
commit
ee7e6886b9
3 changed files with 15 additions and 5 deletions
11
README.md
11
README.md
|
|
@ -34,9 +34,10 @@ Syntax of a rule file (placed under [rules](./rules)):
|
|||
# this field should be the name of the command
|
||||
command = "world"
|
||||
|
||||
# you can add as much section of this as you like
|
||||
[[match_output]]
|
||||
# the suggestion of this section will be used for the following patterns of the command output
|
||||
# you can add as many `[[match_err]]` section as you want
|
||||
[[match_err]]
|
||||
# the suggestion of this section will be used for the following patterns of the error output
|
||||
# note that the error is formatted to lowercase without extra spaces
|
||||
pattern = [
|
||||
"pattern 1",
|
||||
"pattern 2",
|
||||
|
|
@ -44,7 +45,7 @@ pattern = [
|
|||
# this will change the first argument to `fix`, while keeping the rest intact
|
||||
suggest = "{{command[0]}} fix {{command[2:]}}"
|
||||
|
||||
[[match_output]]
|
||||
[[match_err]]
|
||||
pattern = [
|
||||
"pattern 1",
|
||||
]
|
||||
|
|
@ -68,6 +69,8 @@ The suggestion can have additional conditions to check. To specify the condition
|
|||
- `cmd_contains`: Check if the last user input contains the argument
|
||||
- `err_contains`: Check if the error of the command contains the argument
|
||||
|
||||
|
||||
|
||||
## Current Progress
|
||||
|
||||
We need more rule files!
|
||||
|
|
|
|||
|
|
@ -49,7 +49,11 @@ fn gen_string_hashmap(rules: Vec<Rule>) -> String {
|
|||
.iter()
|
||||
.map(|x| x.to_lowercase())
|
||||
.collect::<Vec<String>>();
|
||||
let suggest = match_err.suggest;
|
||||
let suggest = match_err.
|
||||
suggest
|
||||
.iter()
|
||||
.map(|x| x.to_lowercase())
|
||||
.collect::<Vec<String>>();
|
||||
string_hashmap.push_str(&format!(
|
||||
"(vec![\"{}\"], vec![\"{}\"]),",
|
||||
pattern.join("\", \""),
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ pub fn command_output(shell: &str, command: &str) -> String {
|
|||
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
.to_string()
|
||||
.split_whitespace()
|
||||
.collect::<Vec<&str>>()
|
||||
.join(" ")
|
||||
.to_lowercase()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue