From d8b9392bad8ea3c3bcf52291f93a86cbeb430be0 Mon Sep 17 00:00:00 2001 From: Able Date: Mon, 5 Dec 2022 04:14:26 -0600 Subject: [PATCH] Update shell version --- Cargo.lock | 1 + libraries/versioning/src/lib.rs | 2 +- programs/shell/Cargo.toml | 1 + programs/shell/src/main.rs | 11 ++++++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88e5e2c..c7224f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -237,6 +237,7 @@ name = "shell" version = "0.1.0" dependencies = [ "clparse", + "versioning", ] [[package]] diff --git a/libraries/versioning/src/lib.rs b/libraries/versioning/src/lib.rs index eedc2ff..81113c1 100644 --- a/libraries/versioning/src/lib.rs +++ b/libraries/versioning/src/lib.rs @@ -41,7 +41,7 @@ impl Version { impl Display for Version { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "v{}.{}.{}", self.major, self.minor, self.patch)?; + write!(f, "{}.{}.{}", self.major, self.minor, self.patch)?; Ok(()) } } diff --git a/programs/shell/Cargo.toml b/programs/shell/Cargo.toml index b033ed0..941233e 100644 --- a/programs/shell/Cargo.toml +++ b/programs/shell/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" [dependencies] clparse = { path = "../../libraries/clparse" } +versioning = { path = "../../libraries/versioning" } diff --git a/programs/shell/src/main.rs b/programs/shell/src/main.rs index 0b8f994..a1abf51 100644 --- a/programs/shell/src/main.rs +++ b/programs/shell/src/main.rs @@ -5,7 +5,9 @@ use std::{ process::{Child, Command, Stdio}, }; -const VERSION: &str = env!("CARGO_PKG_VERSION"); +use versioning::Version; + +pub const VERSION: Version = Version::new(0, 1, 0); fn main() { let ret = clparse::Arguments::parse_from_args().unwrap(); let config = ret.0; @@ -55,3 +57,10 @@ fn main() { } } } + +#[test] +fn sanity_check_version() { + let cargo_version = env!("CARGO_PKG_VERSION"); + let str_version = format!("{}", VERSION); + assert_eq!(str_version, cargo_version); +}