use std::str::FromStr;
use cfg_if::cfg_if;
use mime::Mime;
use once_cell::sync::Lazy;
use crate::String;
pub const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
cfg_if! {
if #[cfg(any(all(unix, feature = "infer-backend"), all(not(unix), not(feature = "xdg-mime-backend"))))] {
pub const BACKEND: &str = "Infer";
} else {
pub const BACKEND: &str = "XDG-Mime";
}
}
pub(crate) static CLAP_VERSION: Lazy<String> = Lazy::new(|| String::from("v") + VERSION.unwrap_or("???"));
pub static CLAP_LONG_VERSION: Lazy<String> = Lazy::new(|| {
let commit = match option_env!("GIT_SHA") {
Some(hash) if !hash.trim().is_empty() => String::from("commit #") + hash,
_ => String::from("unknown commit"),
};
format!("v{} ({}, {} backend, {})", VERSION.unwrap_or("???"), os_name(), BACKEND, commit).into()
});
pub static APPLICATION_ZIP: Lazy<Mime> = Lazy::new(|| Mime::from_str("application/zip").unwrap());
#[allow(clippy::option_map_unit_fn)]
pub fn os_name() -> String {
match std::env::consts::OS {
"ios" => "iOS".into(),
"macos" => "macOS".into(),
"freebsd" => "FreeBSD".into(),
"openbsd" => "OpenBSD".into(),
"netbsd" => "NetBSD".into(),
"vxworks" => "VxWorks".into(),
os => {
let mut os_upper = String::from(os);
os_upper.get_mut(0..1).map(|first| first.make_ascii_uppercase());
os_upper
}
}
}