Output abstraction for printing results
| 7 | |
| 8 | /// Output abstraction for printing results |
| 9 | pub trait Output: Send + Sync { |
| 10 | /// Print normal output |
| 11 | fn print(&self, msg: &str) -> CliResult<()>; |
| 12 | |
| 13 | /// Print formatted JSON |
| 14 | fn print_json(&self, data: &serde_json::Value) -> CliResult<()> { |
| 15 | self.print(&serde_json::to_string_pretty(data)?) |
| 16 | } |
| 17 | |
| 18 | /// Print error message |
| 19 | fn error(&self, msg: &str) -> CliResult<()>; |
| 20 | |
| 21 | /// Print success message with checkmark |
| 22 | fn success(&self, msg: &str) -> CliResult<()> { |
| 23 | self.print(&format!("✅ {}", msg)) |
| 24 | } |
| 25 | |
| 26 | /// Print warning message |
| 27 | fn warning(&self, msg: &str) -> CliResult<()> { |
| 28 | self.print(&format!("⚠️ {}", msg)) |
| 29 | } |
| 30 | |
| 31 | /// Print info message |
| 32 | fn info(&self, msg: &str) -> CliResult<()> { |
| 33 | self.print(&format!("ℹ️ {}", msg)) |
| 34 | } |
| 35 | |
| 36 | /// Print a section header |
| 37 | fn header(&self, title: &str) -> CliResult<()> { |
| 38 | self.print(&format!("\n{}\n{}", title, "=".repeat(title.len()))) |
| 39 | } |
| 40 | |
| 41 | /// Print a subsection header |
| 42 | fn subheader(&self, title: &str) -> CliResult<()> { |
| 43 | self.print(&format!("\n{}\n{}", title, "-".repeat(title.len()))) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /// Standard console output implementation |
| 48 | pub struct ConsoleOutput; |
no outgoing calls
no test coverage detected