OXYGENHUB
# 5d695d869fbf spectra / src / cli / marks.rs
1.0 KiB · Rust · last changed The command line in oxy's style: ticks and verbs, key-value rows, sections, hints, spinners; plain when piped 2 days ago source blame history raw
5d695d86 Andy McCall ↶ 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.
8
#[allow(dead_code)] // Used by agent list once presence lands (#5).
9
pub fn presence(state: &str) -> String {
10
    let (g, a) = match state {
11
        "online" => ("●", "*"),
12
        "busy" => ("◆", "+"),
13
        "idle" => ("◌", "o"),
14
        "blocked" => ("‼", "!"),
15
        "paused" => ("⏸", "="),
16
        _ => ("○", "-"),
17
    };
18
    let text = format!("{} {state:<7}", glyph(g, a));
19
    match state {
20
        "online" => ok(text),
21
        "busy" => style(text).cyan().to_string(),
22
        "blocked" | "paused" => warn(text),
23
        _ => dim(text),
24
    }
25
}
26
27
/// Whether an agent may act: a tick, or a warning with the reason.
28
pub fn health(state: &str) -> String {
29
    if state == "ok" {
30
        ok(glyph("✔", "ok"))
31
    } else {
32
        warn(glyph("⚠", "!"))
33
    }
34
}