cardanowall_cli/util/version.rs
1//! The `--version` string, stamped at compile time by `build.rs`.
2//!
3//! Carries the package version, the short git SHA, and the UTC build date so a
4//! deployed binary self-identifies its provenance.
5
6/// The version line clap appends after the binary name, e.g.
7/// `0.0.0 (git abc123, built 2026-06-01)` — clap renders it as
8/// `cardanowall 0.0.0 (git abc123, built 2026-06-01)`.
9///
10/// Returned as a `&'static str` so it can feed clap's `version` attribute (which
11/// requires a value convertible to a static string). The components are all
12/// compile-time `env!` constants, so the line is assembled once and cached. The
13/// binary name is omitted here because clap prepends it.
14#[must_use]
15pub fn version_string() -> &'static str {
16 use std::sync::OnceLock;
17 static VERSION: OnceLock<String> = OnceLock::new();
18 VERSION
19 .get_or_init(|| {
20 format!(
21 "{} (git {}, built {})",
22 env!("CARDANOWALL_CLI_VERSION"),
23 env!("CARDANOWALL_CLI_GIT_SHA"),
24 env!("CARDANOWALL_CLI_BUILD_DATE"),
25 )
26 })
27 .as_str()
28}