use roneo_core::{ActionEvent, Reporter}; use crate::style; #[derive(Debug, Clone, Copy)] pub struct ConsoleReporter { pub quiet: bool, pub pretend: bool, } impl Reporter for ConsoleReporter { fn emit(&self, event: ActionEvent) { if self.quiet { if let ActionEvent::Conflict(path) = event { eprintln!(" {:>10} {}", style::red_bold("conflict"), path.display()); } return; } let prefix = if self.pretend { format!("{} ", style::dim("[dry-run]")) } else { String::new() }; match event { ActionEvent::Create(p) => { println!( " {prefix}{:>10} {}", style::green_bold("create"), p.display() ); } ActionEvent::Overwrite(p) => { println!( " {prefix}{:>10} {}", style::yellow_bold("overwrite"), p.display() ); } ActionEvent::Update(p) => { println!( " {prefix}{:>10} {}", style::cyan_bold("update"), p.display() ); } ActionEvent::Delete(p) => { println!( " {prefix}{:>10} {}", style::red_bold("delete"), p.display() ); } ActionEvent::Identical(p) => { println!(" {prefix}{:>10} {}", style::dim("identical"), p.display()); } ActionEvent::Skip(p) => { println!(" {prefix}{:>10} {}", style::blue("skip"), p.display()); } ActionEvent::Conflict(p) => { eprintln!( " {prefix}{:>10} {}", style::red_bold("conflict"), p.display() ); } ActionEvent::RunTask(cmd) => { println!(" {prefix}{:>10} {}", style::magenta_bold("run"), cmd); } ActionEvent::Message(msg) => { println!("\n{msg}\n"); } ActionEvent::Warning(warn) => { eprintln!(" {:>10} {}", style::yellow_bold("warning"), warn); } } } }