surrealpatch/src/cli/version.rs

28 lines
617 B
Rust
Raw Normal View History

2020-06-29 15:36:01 +00:00
use clap;
use failure::Error;
const NAME: &'static str = env!("CARGO_PKG_NAME");
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
macro_rules! get_cfg {
($i:ident : $($s:expr),+) => (
let $i = || { $( if cfg!($i=$s) { return $s; } );+ "unknown"};
)
}
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()
);
Ok(())
}