From 75c3d4be13a5d5f525ee1ff8bc68e3c1ce0f7509 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 3 Oct 2021 16:58:19 +0530 Subject: don't report fix on stderr --- bin/src/main.rs | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/bin/src/main.rs b/bin/src/main.rs index 71cbb02..ab99aee 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -5,8 +5,8 @@ use std::{ use anyhow::{Context, Result}; use ariadne::{ - CharSet, Color, Config as CliConfig, Label, Report as CliReport, - ReportKind as CliReportKind, Source, LabelAttach + CharSet, Color, Config as CliConfig, Label, LabelAttach, Report as CliReport, + ReportKind as CliReportKind, Source, }; use lib::{Report, LINTS}; use rnix::{TextRange, WalkEvent}; @@ -44,31 +44,21 @@ fn print_report(report: Report, file_src: &str, file_path: &Path) -> Result<()> .iter() .fold( CliReport::build(CliReportKind::Warning, src_id, offset) - .with_config( - CliConfig::default() - .with_cross_gap(true) - .with_multiline_arrows(false) - .with_label_attach(LabelAttach::Middle) - .with_char_set(CharSet::Unicode), - ) - .with_message(report.note) - .with_code(report.code), + .with_config( + CliConfig::default() + .with_cross_gap(true) + .with_multiline_arrows(false) + .with_label_attach(LabelAttach::Middle) + .with_char_set(CharSet::Unicode), + ) + .with_message(report.note) + .with_code(report.code), |cli_report, diagnostic| { - let cli_report = cli_report.with_label( + cli_report.with_label( Label::new((src_id, range(diagnostic.at))) .with_message(&diagnostic.message) .with_color(Color::Magenta), - ); - if let Some(s) = &diagnostic.suggestion { - let replacement_msg = format!("Try: `{}`", s.fix); - cli_report.with_label( - Label::new((src_id, range(s.at))) - .with_message(replacement_msg) - .with_color(Color::Yellow), - ) - } else { - cli_report - } + ) }, ) .finish() @@ -96,6 +86,7 @@ fn _main() -> Result<()> { } Ok(()) } + fn main() { match _main() { Err(e) => eprintln!("{}", e), -- cgit v1.2.3