Skip to content

Commit

Permalink
semver compare
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodesdev committed Nov 8, 2024
1 parent 7aaf176 commit 1812a8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rustfinity"
version = "0.2.11"
version = "0.2.12"
edition = "2021"
license = "MIT"
description = "Rustfinity.com CLI"
Expand All @@ -13,6 +13,7 @@ clap = { version = "4.5.4", features = ["derive"] }
dload = "0.1"
futures = "0.3.30"
reqwest = { version = "0.12.4", features = ["json"] }
semver = "1.0.23"
serde_json = "1.0.117"
tokio = { version = "1.37.0", features = ["full"] }
urlencoding = "2.1.3"
Expand Down
9 changes: 7 additions & 2 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ mod editor;

use clap::Parser;
use cli::{run, Cli};
use semver;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let latest_version = crates_io::get_latest_version().await?;
let latest_version = semver::Version::parse(&latest_version)?;

let current_version = env!("CARGO_PKG_VERSION");
let current_version = semver::Version::parse(current_version)?;

if latest_version != current_version {
if latest_version > current_version {
println!(
"A new version of rustfinity ({}) is available, please run the following command and try again:\n\n$ cargo install rustfinity",
"A new version of rustfinity ({}) is available, please run the following command and try again:",
latest_version
);
println!("$ cargo install rustfinity");
return Ok(());
}

Expand Down

0 comments on commit 1812a8c

Please sign in to comment.