pub mod hyperlink;
pub mod linkify;
pub use linkify::linkify_text;
pub fn resolve_tz(override_iana: Option<&str>) -> chrono_tz::Tz {
use std::str::FromStr;
if let Some(name) = override_iana {
if let Ok(tz) = chrono_tz::Tz::from_str(name) {
return tz;
}
}
let local = iana_time_zone::get_timezone()
.ok()
.unwrap_or_else(|| "UTC".to_string());
chrono_tz::Tz::from_str(&local).unwrap_or(chrono_tz::UTC)
}
use std::sync::atomic::{AtomicBool, Ordering};
static NO_COLOR: AtomicBool = AtomicBool::new(false);
pub fn set_no_color(value: bool) {
NO_COLOR.store(value, Ordering::Relaxed);
}
pub fn no_color() -> bool {
NO_COLOR.load(Ordering::Relaxed)
}
pub fn install_inquire_theme() {
if no_color() {
return;
}
use inquire::ui::{Attributes, Color, RenderConfig, StyleSheet, Styled};
let label_style = StyleSheet::new()
.with_fg(Color::LightCyan)
.with_attr(Attributes::BOLD);
let mut config = RenderConfig::default()
.with_prompt_prefix(Styled::new("?").with_fg(Color::LightYellow))
.with_answered_prompt_prefix(Styled::new("✔").with_fg(Color::LightGreen))
.with_help_message(StyleSheet::new().with_fg(Color::DarkGrey))
.with_default_value(
StyleSheet::new()
.with_fg(Color::DarkGrey)
.with_attr(Attributes::ITALIC),
)
.with_canceled_prompt_indicator(Styled::new("<canceled>").with_fg(Color::LightRed));
config.prompt = label_style;
config.editor_prompt = label_style;
inquire::set_global_render_config(config);
}