style: better formating from AI

This commit is contained in:
iff 2024-11-19 15:15:47 +01:00
parent 5d7624563d
commit 51b719c850

View file

@ -60,7 +60,22 @@ pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Opti
use crate::requests::ai_suggestion;
let suggest = ai_suggestion(last_command, error_msg);
if let Some(suggest) = suggest {
eprintln!("{}: {}\n", t!("ai-suggestion").bold().blue(), suggest.note);
let suggest_note = suggest.note.split_whitespace().collect::<Vec<&str>>();
let mut note = String::new();
let mut line = String::new();
for word in suggest_note {
if line.len() + word.len() > 80 {
note.push_str(&line);
note.push('\n');
line.clear();
}
line.push_str(word);
line.push(' ');
}
note.push_str(&line);
let warn = format!("{}:", t!("ai-suggestion")).bold().blue();
eprintln!("{}\n{}\n", warn, note);
let command = suggest.command;
if command != "None" {
if PRIVILEGE_LIST.contains(&split_command[0].as_str()) {