Skip to content

Commit

Permalink
Build CLI: Always show message on mismatch versions.
Browse files Browse the repository at this point in the history
Print info message if the version of the installed cli tool is more
recent than the local repo as well, but make it as info message since
it's less likely to cause problems than the other way.
  • Loading branch information
AmmarAbouZor committed Jan 22, 2025
1 parent 2051ac7 commit 23e046c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions cli/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Manages Comparing the current version of the binary to the version of this CLI tool from the
//! current local repository of the user, printing a message to the user on newer editions.
use std::{fmt::Display, str::FromStr};
use std::{cmp::Ordering, fmt::Display, str::FromStr};

use anyhow::{ensure, Context};
use console::style;
Expand Down Expand Up @@ -65,9 +65,22 @@ fn try_check_version() -> anyhow::Result<()> {
format!("Parsing local repo version text failed. Version: {repo_version}")
})?;

if repo_version > bin_version {
let warn_msg = format!("A newer version of the Build CLI Tool is available in your local repository\nInstalled Version: {bin_version}\nLatest Version: {repo_version}\n");
eprintln!("{}", style(warn_msg).yellow());
match repo_version.cmp(&bin_version) {
Ordering::Less => {
let info_msg = format!("The version of the installed Build CLI Tool is more recent than the current one in the local repository\n\
Installed Version: {bin_version}\n\
Local repo Version: {repo_version}\n");
eprintln!("{}", style(info_msg).cyan());
}
Ordering::Equal => {}
Ordering::Greater => {
let warn_msg = format!(
"A newer version of the Build CLI Tool is available in the local repository\n\
Installed Version: {bin_version}\n\
Local repo Version: {repo_version}\n"
);
eprintln!("{}", style(warn_msg).yellow());
}
}

Ok(())
Expand Down

0 comments on commit 23e046c

Please sign in to comment.