From 4e10a981b2fd74dc2f559484e52021cd79aef7e5 Mon Sep 17 00:00:00 2001 From: Nadja Reitzenstein Date: Wed, 27 Apr 2022 17:21:45 +0200 Subject: [PATCH] Return full version string for --version Fixes #53 --- Cargo.lock | 2 +- bffhd/lib.rs | 3 ++- bin/bffhd/main.rs | 1 + build.rs | 9 +++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1623ed1..781b10a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2028,7 +2028,7 @@ dependencies = [ [[package]] name = "rsasl" version = "2.0.0-preview4" -source = "git+https://github.com/dequbed/rsasl.git?branch=main#0b5012d0934925aed6eb8463b397c512a2cffbd9" +source = "git+https://github.com/dequbed/rsasl.git?rev=0b5012d0#0b5012d0934925aed6eb8463b397c512a2cffbd9" dependencies = [ "libc", "linkme", diff --git a/bffhd/lib.rs b/bffhd/lib.rs index de2ba9d..83cf2ab 100644 --- a/bffhd/lib.rs +++ b/bffhd/lib.rs @@ -64,6 +64,7 @@ use crate::tls::TlsConfig; use crate::users::db::UserDB; use crate::users::Users; +pub const VERSION_STRING: &'static str = env!("BFFHD_VERSION_STRING"); pub const RELEASE_STRING: &'static str = env!("BFFHD_RELEASE_STRING"); pub struct Diflouroborane { @@ -80,7 +81,7 @@ pub static RESOURCES: OnceCell = OnceCell::new(); impl Diflouroborane { pub fn new(config: Config) -> anyhow::Result { logging::init(&config.logging); - tracing::info!(version=RELEASE_STRING, "Starting"); + tracing::info!(version=VERSION_STRING, "Starting BFFH"); let span = tracing::info_span!("setup"); let _guard = span.enter(); diff --git a/bin/bffhd/main.rs b/bin/bffhd/main.rs index 4f06659..43a2dde 100644 --- a/bin/bffhd/main.rs +++ b/bin/bffhd/main.rs @@ -16,6 +16,7 @@ fn main() -> anyhow::Result<()> { // values for the name, description and version are pulled from `Cargo.toml`. let matches = Command::new(clap::crate_name!()) .version(clap::crate_version!()) + .long_version(diflouroborane::VERSION_STRING) .about(clap::crate_description!()) .arg( Arg::new("config") diff --git a/build.rs b/build.rs index d684242..aa45bc4 100644 --- a/build.rs +++ b/build.rs @@ -14,8 +14,8 @@ fn main() { println!("cargo:rerun-if-env-changed=BFFHD_BUILD_TAGGED_RELEASE"); let tagged_release = option_env!("BFFHD_BUILD_TAGGED_RELEASE") == Some("1"); - let release = if tagged_release { - format!("BFFH {version} [{rustc}]", + let version_string = if tagged_release { + format!("{version} [{rustc}]", version = env!("CARGO_PKG_VERSION"), rustc = rustc_version) } else { @@ -40,11 +40,12 @@ fn main() { .expect("git log output was not valid UTF8"); let commit_date = commit_date.trim(); - format!("BFFH {version} ({gitrev} {date}) [{rustc}]", + format!("{version} ({gitrev} {date}) [{rustc}]", version=env!("CARGO_PKG_VERSION"), gitrev=abbrev, date=commit_date, rustc=rustc_version) }; - println!("cargo:rustc-env=BFFHD_RELEASE_STRING={}", release); + println!("cargo:rustc-env=BFFHD_VERSION_STRING={}", version_string); + println!("cargo:rustc-env=BFFHD_RELEASE_STRING=\"BFFH {}\"", version_string); }