OXYGENHUB

Coverage / src/cli/marks.rs 95.0%

19 of 20 lines run, 2 of 4 functions · run #19 on main · run missed

1
//! Spectra's own marks, in the style of `oxy`'s (`ui.rs` stays exactly
2
//! `oxy`'s, so the two tools look the same): presence and agent health.
3
4
use super::ui::{dim, glyph, ok, warn};
5
use console::style;
6
7
/// An agent's presence (spec §8.1) as a coloured glyph and word.
81×
pub fn presence(state: &str) -> String {
91×
    let (g, a) = match state {
101×
        "online" => ("●", "*"),
111×
        "busy" => ("◆", "+"),
121×
        "idle" => ("◌", "o"),
131×
        "blocked" => ("‼", "!"),
141×
        "paused" => ("⏸", "="),
151×
        _ => ("○", "-"),
16
    };
171×
    let text = format!("{} {state:<7}", glyph(g, a));
181×
    match state {
191×
        "online" => ok(text),
201×
        "busy" => style(text).cyan().to_string(),
211×
        "blocked" | "paused" => warn(text),
221×
        _ => dim(text),
23
    }
241×
}
25
26
/// Whether an agent may act: a tick, or a warning with the reason.
271×
pub fn health(state: &str) -> String {
281×
    if state == "ok" {
290×
        ok(glyph("✔", "ok"))
30
    } else {
311×
        warn(glyph("⚠", "!"))
32
    }
331×
}