fix: some error handlings

This commit is contained in:
iff 2023-08-07 20:21:02 +02:00
parent 1444eeab84
commit 15c1ba3370
7 changed files with 49 additions and 37 deletions

View file

@ -1,5 +1,5 @@
use colored::Colorize;
use crate::style::highlight_difference;
use colored::Colorize;
mod args;
mod files;
@ -15,21 +15,27 @@ fn main() {
);
let mut last_command = shell::last_command_expanded_alias(&shell);
loop {
let corrected_command = suggestions::suggest_command(&shell, &last_command);
if let Some(corrected_command) = corrected_command {
let command_difference = highlight_difference(&shell, &corrected_command, &last_command);
let command_difference =
highlight_difference(&shell, &corrected_command, &last_command);
if let Some(highlighted_command) = command_difference {
let execution = suggestions::confirm_suggestion(&shell, &corrected_command, &highlighted_command);
let execution = suggestions::confirm_suggestion(
&shell,
&corrected_command,
&highlighted_command,
);
if execution.is_ok() {
return;
}
else {
let retry_message = format!("{}", "Looking for new suggestion...".cyan().bold());
} else {
let retry_message =
format!("{}", "Looking for new suggestion...".cyan().bold());
println!("\n{}\n", retry_message);
last_command = corrected_command;
}
} else {
break;
}
} else {
break;