Skip to main content

yui/
icons.rs

1//! Icon character sets for terminal output.
2//!
3//! Three modes (see [`crate::config::IconsMode`]):
4//!   - `Unicode` (default): `✓ ✗ → ─` — universally renderable
5//!   - `Nerd`: Nerd-Font glyphs — requires a patched font
6//!   - `Ascii`: `[+] [-] -> -` — pure ASCII fallback for CI logs
7
8use crate::config::IconsMode;
9
10#[derive(Debug, Clone, Copy)]
11pub struct Icons {
12    pub active: &'static str,
13    pub inactive: &'static str,
14    pub arrow: &'static str,
15    pub sep: char,
16    /// `yui status` — link is intact (in-sync).
17    pub ok: &'static str,
18    /// `yui status` — informational (e.g. target missing, will be created).
19    pub info: &'static str,
20    /// `yui status` — drift detected, but auto-fixable.
21    pub warn: &'static str,
22    /// `yui status` — anomaly that needs user attention.
23    pub error: &'static str,
24}
25
26impl Icons {
27    pub const UNICODE: Self = Self {
28        active: "\u{2713}",   // ✓
29        inactive: "\u{2717}", // ✗
30        arrow: "\u{2192}",    // →
31        sep: '\u{2500}',      // ─
32        ok: "\u{2713}",       // ✓
33        info: "\u{25cb}",     // ○
34        warn: "\u{26a0}",     // ⚠
35        error: "\u{2717}",    // ✗
36    };
37    pub const NERD: Self = Self {
38        active: "\u{f058}",   //   nf-fa-check_circle
39        inactive: "\u{f057}", //   nf-fa-times_circle
40        arrow: "\u{2192}",    // → (no need for a special arrow glyph)
41        sep: '\u{2500}',      // ─
42        ok: "\u{f058}",       //   nf-fa-check_circle
43        info: "\u{f05a}",     //   nf-fa-info_circle
44        warn: "\u{f071}",     //   nf-fa-warning
45        error: "\u{f057}",    //   nf-fa-times_circle
46    };
47    pub const ASCII: Self = Self {
48        active: "[+]",
49        inactive: "[-]",
50        arrow: "->",
51        sep: '-',
52        ok: "[+]",
53        info: "[.]",
54        warn: "[!]",
55        error: "[-]",
56    };
57
58    pub const fn for_mode(mode: IconsMode) -> Self {
59        match mode {
60            IconsMode::Unicode => Self::UNICODE,
61            IconsMode::Nerd => Self::NERD,
62            IconsMode::Ascii => Self::ASCII,
63        }
64    }
65}