Return full version string for --version

Fixes #53
This commit is contained in:
Nadja Reitzenstein 2022-04-27 17:21:45 +02:00
parent 4ca4dc124b
commit 4e10a981b2
4 changed files with 9 additions and 6 deletions

2
Cargo.lock generated
View File

@ -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",

View File

@ -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<ResourcesHandle> = OnceCell::new();
impl Diflouroborane {
pub fn new(config: Config) -> anyhow::Result<Self> {
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();

View File

@ -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")

View File

@ -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);
}