diff --git a/crates/pacdef_core/src/core.rs b/crates/pacdef_core/src/core.rs index d7e5844..8092ca2 100644 --- a/crates/pacdef_core/src/core.rs +++ b/crates/pacdef_core/src/core.rs @@ -147,7 +147,7 @@ impl Pacdef { #[allow(clippy::unused_self)] fn show_version(self) { - println!("{}", get_version_string()); + println!("{}", get_name_and_version()); } fn show_unmanaged_packages(mut self) -> Result<()> { @@ -348,8 +348,16 @@ fn show_error(error: &anyhow::Error, backend: &dyn Backend) { } } +/// If the crate was compiled from git, return `pacdef, ()`. +/// Otherwise return `pacdef, `. +const fn get_name_and_version() -> &'static str { + formatcp!("pacdef, version {}", get_version_string()) +} + +/// If the crate was compiled from git, return ` ()`. Otherwise +/// return ``. pub const fn get_version_string() -> &'static str { - const VERSION: &str = concat!("pacdef, version: ", env!("CARGO_PKG_VERSION")); + const VERSION: &str = env!("CARGO_PKG_VERSION"); const HASH: &str = env!("GIT_HASH"); if HASH.is_empty() {