fix: not output when sucessfully executed the command

This commit is contained in:
iff 2023-08-09 16:50:45 +02:00
parent 6a1b7fb246
commit a201c18c01
2 changed files with 10 additions and 5 deletions

View file

@ -46,11 +46,15 @@ fn main() {
if execution.is_ok() {
return;
} else {
last_command = corrected_command;
let msg = execution.err().unwrap();
error_msg = msg.to_lowercase();
let retry_message =
format!("{}", "Looking for new suggestion...".cyan().bold());
println!("\n{} {}", "ERROR:".red().bold(), msg);
println!("\n{}\n", retry_message);
last_command = corrected_command;
error_msg = execution.err().unwrap();
}
} else {
break;

View file

@ -5,7 +5,7 @@ use regex_lite::Regex;
use rule_parser::parse_rules;
use crate::files::{get_best_match_file, get_path_files};
use crate::shell::{PRIVILEGE_LIST};
use crate::shell::PRIVILEGE_LIST;
pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Option<String> {
let split_command = split_command(last_command);
@ -199,7 +199,7 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
.arg("-c")
.arg(command)
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.expect("failed to execute process");
@ -215,7 +215,8 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
let process = std::process::Command::new(shell)
.arg("-c")
.arg(command)
.stdout(Stdio::piped())
.stdout(Stdio::inherit())
.stderr(Stdio::piped())
.output()
.expect("failed to execute process");