(preference: &str)
| 135 | } |
| 136 | |
| 137 | pub fn resolve_appearance(preference: &str) -> Appearance { |
| 138 | match preference.trim().to_ascii_lowercase().as_str() { |
| 139 | "light" => Appearance::Light, |
| 140 | "auto" => { |
| 141 | detect_terminal_appearance(Duration::from_millis(250)).unwrap_or(Appearance::Dark) |
| 142 | } |
| 143 | _ => Appearance::Dark, |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | fn detect_terminal_appearance(timeout: Duration) -> Option<Appearance> { |
| 148 | if std::env::var_os("NO_COLOR").is_some() { |
no test coverage detected