1use super::State;
2
3fn choose(list: &'static [Option<&'static str>]) -> &'static str {
4 list.iter()
5 .filter_map(|&x| x)
6 .find(|s| !s.is_empty() && !s.contains(char::is_control))
7 .unwrap_or(&"<unknown>")
8}
9
10lazy_static! {
11 pub(super) static ref NAME_STR: &'static str = choose(&[option_env!("CARGO_PKG_NAME")]);
12 pub(super) static ref VERSION_STR: &'static str = choose(&[
13 option_env!("IRC_BOT_RS_GIT_VERSION"),
14 option_env!("CARGO_PKG_VERSION"),
15 ]);
16 pub(super) static ref HOMEPAGE_STR: &'static str = choose(&[option_env!("CARGO_PKG_HOMEPAGE")]);
17 pub(super) static ref BRIEF_CREDITS_STRING: String = format!(
18 "Built with <{url}> {ver}",
19 url = HOMEPAGE_STR.deref(),
20 ver = VERSION_STR.deref(),
21 );
22}
23
24impl State {
25 pub fn framework_crate_name(&self) -> &'static str {
27 &NAME_STR
28 }
29
30 pub fn framework_version_str(&self) -> &'static str {
38 &VERSION_STR
39 }
40
41 pub fn framework_homepage_url_str(&self) -> &'static str {
46 &HOMEPAGE_STR
47 }
48}