diff --git a/src/main.rs b/src/main.rs index aed0392..eea7959 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; diff --git a/src/suggestions.rs b/src/suggestions.rs index 1cd5ac2..3712cf0 100644 --- a/src/suggestions.rs +++ b/src/suggestions.rs @@ -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 { 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");