Skip to main content

theater_cli/output/
theme.rs

1use console::Style;
2
3/// Theme for consistent CLI styling
4#[derive(Debug, Clone)]
5pub struct Theme {
6    pub success: Style,
7    pub error: Style,
8    pub warning: Style,
9    pub info: Style,
10    pub accent: Style,
11    pub muted: Style,
12    pub highlight: Style,
13    pub table_header: Style,
14}
15
16impl Theme {
17    /// Create a colored theme
18    pub fn colored() -> Self {
19        Self {
20            success: Style::new().green().bold(),
21            error: Style::new().red().bold(),
22            warning: Style::new().yellow().bold(),
23            info: Style::new().blue().bold(),
24            accent: Style::new().cyan(),
25            muted: Style::new().dim(),
26            highlight: Style::new().bright().bold(),
27            table_header: Style::new().bold().underlined(),
28        }
29    }
30
31    /// Create a plain theme (no colors)
32    pub fn plain() -> Self {
33        Self {
34            success: Style::new(),
35            error: Style::new(),
36            warning: Style::new(),
37            info: Style::new(),
38            accent: Style::new(),
39            muted: Style::new(),
40            highlight: Style::new(),
41            table_header: Style::new(),
42        }
43    }
44
45    // Icon methods
46    pub fn success_icon(&self) -> console::StyledObject<&str> {
47        self.success.apply_to("✓")
48    }
49
50    pub fn error_icon(&self) -> console::StyledObject<&str> {
51        self.error.apply_to("✗")
52    }
53
54    pub fn warning_icon(&self) -> console::StyledObject<&str> {
55        self.warning.apply_to("⚠")
56    }
57
58    pub fn info_icon(&self) -> console::StyledObject<&str> {
59        self.info.apply_to("ℹ")
60    }
61
62    // Style accessors
63    pub fn success(&self) -> &Style {
64        &self.success
65    }
66
67    pub fn error(&self) -> &Style {
68        &self.error
69    }
70
71    pub fn warning(&self) -> &Style {
72        &self.warning
73    }
74
75    pub fn info(&self) -> &Style {
76        &self.info
77    }
78
79    pub fn accent(&self) -> &Style {
80        &self.accent
81    }
82
83    pub fn muted(&self) -> &Style {
84        &self.muted
85    }
86
87    pub fn highlight(&self) -> &Style {
88        &self.highlight
89    }
90
91    pub fn table_header(&self) -> &Style {
92        &self.table_header
93    }
94}