1
Fork 0
mirror of https://github.com/RGBCube/dix synced 2025-07-27 19:57:44 +00:00

print: clean up printing

only show the actually changed versions, not all of them.
make the changed bold
This commit is contained in:
Bloxx12 2025-05-08 09:44:03 +02:00
parent 697a72bcef
commit ffc7e56a44
No known key found for this signature in database

View file

@ -19,12 +19,12 @@ fn diff_versions(left: &str, right: &str) -> (String, String) {
post.push(l); post.push(l);
} }
diff::Result::Left(l) => { diff::Result::Left(l) => {
let string_to_push = format!("\x1b[31m{l}"); let string_to_push = format!("\x1b[1;91m{l}");
prev.push_str(&string_to_push); prev.push_str(&string_to_push);
} }
diff::Result::Right(r) => { diff::Result::Right(r) => {
let string_to_push = format!("\x1b[32m{r}"); let string_to_push = format!("\x1b[1;92m{r}");
post.push_str(&string_to_push); post.push_str(&string_to_push);
} }
} }
@ -102,8 +102,8 @@ pub fn print_changes(
changes.sort_by(|(a, _, _), (b, _, _)| a.cmp(b)); changes.sort_by(|(a, _, _), (b, _, _)| a.cmp(b));
for (p, ver_pre, ver_post) in changes { for (p, ver_pre, ver_post) in changes {
let mut version_vec_pre = ver_pre.iter().copied().collect::<Vec<_>>(); let mut version_vec_pre = ver_pre.difference(ver_post).copied().collect::<Vec<_>>();
let mut version_vec_post = ver_post.iter().copied().collect::<Vec<_>>(); let mut version_vec_post = ver_post.difference(ver_pre).copied().collect::<Vec<_>>();
version_vec_pre.sort_unstable(); version_vec_pre.sort_unstable();
version_vec_post.sort_unstable(); version_vec_post.sort_unstable();
@ -129,7 +129,7 @@ pub fn print_changes(
} }
println!( println!(
"[{}] {:col_width$} {} ~> {}", "[{}] {:col_width$} {} \u{00B1} {}",
"C:".bold().bright_yellow(), "C:".bold().bright_yellow(),
p, p,
diffed_pre, diffed_pre,