Align right sharp of new version notification
The right-hand sharp in the line containing
"Current" and "Latest" was not vertically aligned,
so it is now nicely centered by calculating
the number of whitespace characters on the left and right.
@@ -100,13 +100,17 @@ pub(crate) fn is_newer_found(version_string: &str) -> bool {
}
fn print_notification(latest_string: &str) {
+ let pad = 48 - VERSION.chars().count() - latest_string.chars().count();
+ let pad_left = " ".repeat(pad / 2);
+ let pad_right = " ".repeat(pad / 2 + (if pad % 2 == 0 { 0 } else { 1 }));
+
warn!("#####################################################################");
warn!("# #");
warn!("# #");
warn!("# NEW CARGO-MAKE VERSION FOUND!!! #");
warn!(
- "# Current: {}, Latest: {}\t\t\t#",
- VERSION, latest_string
+ "#{}Current: {}, Latest: {}{}#",
+ pad_left, VERSION, latest_string, pad_right
);
warn!("# Run 'cargo install --force cargo-make' to get latest version #");
warn!("# #");
