feat: skip usage errors

This commit is contained in:
iff 2024-11-27 19:55:39 +01:00
parent 8429ce2872
commit ab3534f0ef

View file

@ -60,6 +60,11 @@ pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Opti
{
use crate::requests::ai_suggestion;
use textwrap::{fill, termwidth};
// skip for commands with no arguments,
// very likely to be an error showing the usage
if PRIVILEGE_LIST.contains(&split_command[0].as_str()) && split_command.len() > 2
|| !PRIVILEGE_LIST.contains(&split_command[0].as_str()) && split_command.len() > 1 {
let suggest = ai_suggestion(last_command, error_msg);
if let Some(suggest) = suggest {
let warn = format!("{}:", t!("ai-suggestion")).bold().blue();
@ -75,6 +80,7 @@ pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Opti
}
}
}
}
None
}