clean: remove operations not actively used

This commit is contained in:
iff 2024-09-26 02:20:19 +02:00
parent ead711f504
commit 754214ede3
3 changed files with 12 additions and 19 deletions

View file

@ -79,7 +79,7 @@ command = "world"
# you can add as many `[[match_err]]` section as you want # you can add as many `[[match_err]]` section as you want
[[match_err]] [[match_err]]
# the suggestion of this section will be used for the following patterns of the error output # 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 # note that the error is formatted to lowercase
pattern = [ pattern = [
"pattern 1", "pattern 1",
"pattern 2" "pattern 2"

View file

@ -26,22 +26,9 @@ pub fn command_output(shell: &str, command: &str) -> String {
}); });
match receiver.recv_timeout(Duration::from_secs(3)) { match receiver.recv_timeout(Duration::from_secs(3)) {
Ok(output) => { Ok(output) => match output.stderr.is_empty() {
if !output.stderr.is_empty() { true => String::from_utf8_lossy(&output.stdout).to_lowercase(),
String::from_utf8_lossy(&output.stderr) false => String::from_utf8_lossy(&output.stderr).to_lowercase(),
.to_string()
.split_whitespace()
.collect::<Vec<&str>>()
.join(" ")
.to_lowercase()
} else {
String::from_utf8_lossy(&output.stdout)
.to_string()
.split_whitespace()
.collect::<Vec<&str>>()
.join(" ")
.to_lowercase()
}
} }
Err(_) => { Err(_) => {
use colored::*; use colored::*;

View file

@ -243,7 +243,10 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
.env("LC_ALL", "C") .env("LC_ALL", "C")
.output() .output()
.expect("failed to execute process"); .expect("failed to execute process");
let error_msg = String::from_utf8_lossy(&process.stderr); let error_msg = match process.stderr.is_empty() {
true => String::from_utf8_lossy(&process.stdout),
false => String::from_utf8_lossy(&process.stderr),
};
return Err(error_msg.to_string()); return Err(error_msg.to_string());
} }
} }
@ -273,7 +276,10 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
.env("LC_ALL", "C") .env("LC_ALL", "C")
.output() .output()
.expect("failed to execute process"); .expect("failed to execute process");
let error_msg = String::from_utf8_lossy(&process.stderr); let error_msg = match process.stderr.is_empty() {
true => String::from_utf8_lossy(&process.stdout),
false => String::from_utf8_lossy(&process.stderr),
};
Err(error_msg.to_string()) Err(error_msg.to_string())
} }
} }