Use configuration constants in version cli command
This commit is contained in:
parent
a2619a8d72
commit
7860a205db
1 changed files with 3 additions and 4 deletions
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue