| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
use super::ui::{dim, glyph, ok, warn}; |
| 5 |
use console::style; |
| 6 |
|
| 7 |
|
| 8 |
pub fn presence(state: &str) -> String { |
| 9 |
let (g, a) = match state { |
| 10 |
"online" => ("●", "*"), |
| 11 |
"busy" => ("◆", "+"), |
| 12 |
"idle" => ("◌", "o"), |
| 13 |
"blocked" => ("‼", "!"), |
| 14 |
"paused" => ("⏸", "="), |
| 15 |
_ => ("○", "-"), |
| 16 |
}; |
| 17 |
let text = format!("{} {state:<7}", glyph(g, a)); |
| 18 |
match state { |
| 19 |
"online" => ok(text), |
| 20 |
"busy" => style(text).cyan().to_string(), |
| 21 |
"blocked" | "paused" => warn(text), |
| 22 |
_ => dim(text), |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
pub fn health(state: &str) -> String { |
| 28 |
if state == "ok" { |
| 29 |
ok(glyph("✔", "ok")) |
| 30 |
} else { |
| 31 |
warn(glyph("⚠", "!")) |
| 32 |
} |
| 33 |
} |