use std::sync::Once;
pub fn pkg_name() -> &'static str {
env!("CARGO_PKG_NAME")
}
pub fn pkg_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
pub fn git_sha() -> &'static str {
option_env!("GIT_SHA").unwrap_or("unknown")
}
pub fn git_branch() -> &'static str {
option_env!("GIT_BRANCH").unwrap_or("unknown")
}
pub fn git_dirty() -> &'static str {
option_env!("GIT_DIRTY").unwrap_or("unknown")
}
pub fn rustc_version() -> &'static str {
option_env!("RUSTC_VERSION").unwrap_or("rustc ?")
}
pub fn target_triple() -> &'static str {
option_env!("TARGET_TRIPLE").unwrap_or("target ?")
}
pub fn build_profile() -> &'static str {
option_env!("BUILD_PROFILE").unwrap_or("profile ?")
}
pub fn build_time_unix() -> &'static str {
option_env!("BUILD_TIME_UNIX").unwrap_or("0")
}
pub fn banner() -> String {
format!(
"{} v{} | git:{}@{} ({}) | {} | {}",
pkg_name(),
pkg_version(),
git_sha(),
git_branch(),
git_dirty(),
target_triple(),
rustc_version(),
)
}
pub fn print_banner() {
static ONCE: Once = Once::new();
ONCE.call_once(|| {
println!("{}", banner());
});
}