mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
chore: better output
This commit is contained in:
parent
551edc2828
commit
cf9e6882e6
5 changed files with 100 additions and 24 deletions
|
|
@ -59,23 +59,12 @@ pub fn suggest_command(shell: &str, last_command: &str, error_msg: &str) -> Opti
|
|||
#[cfg(feature = "request-ai")]
|
||||
{
|
||||
use crate::requests::ai_suggestion;
|
||||
use textwrap::{fill, termwidth};
|
||||
let suggest = ai_suggestion(last_command, error_msg);
|
||||
if let Some(suggest) = suggest {
|
||||
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();
|
||||
let note = fill(&suggest.note, termwidth());
|
||||
|
||||
eprintln!("{}\n{}\n", warn, note);
|
||||
let command = suggest.command;
|
||||
if command != "None" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue