surrealpatch/src/cli/version.rs

22 lines
603 B
Rust
Raw Normal View History

2021-03-29 15:43:37 +00:00
use anyhow::Error;
2020-06-29 15:36:01 +00:00
use clap;
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");
2021-03-29 15:43:37 +00:00
println!("{} {} for {} on {}", NAME, VERSION, target_os(), target_arch());
2020-06-29 15:36:01 +00:00
Ok(())
}