Skip to content

Commit b7138f6

Browse files
committed
feat: change spans command to alternate colors
1 parent ec4c8e7 commit b7138f6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

harper-cli/src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,27 @@ fn main() -> anyhow::Result<()> {
9393
let (doc, source) = load_file(&file)?;
9494

9595
let primary_color = Color::Blue;
96+
let secondary_color = Color::Magenta;
9697
let filename = file
9798
.file_name()
9899
.map(|s| s.to_string_lossy().into())
99100
.unwrap_or("<file>".to_string());
100101

101102
let mut report_builder = Report::build(ReportKind::Advice, &filename, 0);
103+
let mut color = primary_color;
102104
for token in doc.tokens() {
103105
report_builder = report_builder.with_label(
104106
Label::new((&filename, token.span.into()))
105107
.with_message(format!("[{}, {})", token.span.start, token.span.end))
106-
.with_color(primary_color),
108+
.with_color(color),
107109
);
110+
111+
// Alternate colors so spans are clear
112+
color = if color == primary_color {
113+
secondary_color
114+
} else {
115+
primary_color
116+
};
108117
}
109118

110119
let report = report_builder.finish();

0 commit comments

Comments
 (0)