Use configuration constants in version cli command

This commit is contained in:
Tobie Morgan Hitchcock 2022-07-19 12:54:45 +01:00
parent a2619a8d72
commit 7860a205db

View file

@ -1,8 +1,7 @@
use crate::cnf::PKG_NAME;
use crate::cnf::PKG_VERS;
use crate::err::Error;
const NAME: &str = env!("CARGO_PKG_NAME");
const VERSION: &str = env!("CARGO_PKG_VERSION");
macro_rules! get_cfg {
($i:ident : $($s:expr),+) => (
let $i = || { $( if cfg!($i=$s) { return $s; } );+ "unknown"};
@ -12,6 +11,6 @@ macro_rules! get_cfg {
pub fn init(_: &clap::ArgMatches) -> Result<(), Error> {
get_cfg!(target_os: "windows", "macos", "ios", "linux", "android", "freebsd", "openbsd", "netbsd");
get_cfg!(target_arch: "x86", "x86_64", "mips", "powerpc", "powerpc64", "arm", "aarch64");
println!("{} {} for {} on {}", NAME, VERSION, target_os(), target_arch());
println!("{} {} for {} on {}", PKG_NAME, PKG_VERS, target_os(), target_arch());
Ok(())
}