Skip to content

Commit

Permalink
Use ANSI colors for bot outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfbacon committed Jan 28, 2024
1 parent 75e691a commit a864f1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions bot/src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async fn render(
progress.reserve(item.len() + 1);
progress.push_str(&item);
progress.push('\n');
let message = format!("Progress: ```\n{}\n```", sanitize_code_block(&progress));
let message = format!("Progress: ```ansi\n{}\n```", sanitize_code_block(&progress));
_ = ctx.say(message).await;
}
})
Expand All @@ -328,7 +328,7 @@ async fn render(
if !res.warnings.is_empty() {
write!(
content,
"Render succeeded with warnings:\n```\n{}\n```",
"Render succeeded with warnings:\n```ansi\n{}\n```",
sanitize_code_block(&res.warnings),
)
.unwrap();
Expand All @@ -342,7 +342,7 @@ async fn render(
}
Err(error) => {
let message = format!(
"An error occurred:\n```\n{}\n```",
"An error occurred:\n```ansi\n{}\n```",
sanitize_code_block(&format!("{error:?}")),
);
ctx.reply(message).await?;
Expand Down Expand Up @@ -410,12 +410,12 @@ async fn ast(

match res {
Ok(ast) => {
let message = format!("```{}```", sanitize_code_block(&ast));
let message = format!("```ansi\n{}```", sanitize_code_block(&ast));
ctx.reply(message).await?;
}
Err(error) => {
let message = format!(
"An error occurred:\n```\n{}```",
"An error occurred:\n```ansi\n{}```",
sanitize_code_block(&format!("{error:?}")),
);
ctx.reply(message).await?;
Expand Down Expand Up @@ -443,7 +443,7 @@ async fn version(ctx: Context<'_>) -> Result<(), PoiseError> {
ctx.reply(message).await?;
}
Err(error) => {
let message = format!("An error occurred:\n```\n{error}```");
let message = format!("An error occurred:\n```ansi\n{error}```");
ctx.reply(message).await?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion worker/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn format_diagnostics(sandbox: &WithSource, diagnostics: &[SourceDiagnostic]
let report_pos = span.map_or(0, |span| span.char_span_start);

let mut report = Report::build(report_kind, source_id, report_pos)
.with_config(Config::default().with_tab_width(2).with_color(false))
.with_config(Config::default().with_tab_width(2).with_color(true))
.with_message(&diagnostic.message);

if let Some(span) = span {
Expand Down

0 comments on commit a864f1b

Please sign in to comment.