plot/lib/display/
config.rs1use super::{Color, DrawTree, Icon};
2use crate::lib::logic::{ConfigJob, ConfigManifest};
3
4impl std::fmt::Display for ConfigJob {
5 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6 let name = self.name.as_deref().unwrap_or("Brak nazwy");
7 let desc = self.description.as_deref().unwrap_or("Brak opisu");
8
9 let quiet_status = if self.quiet_work { "🤫 Cichy (Quiet)" } else { "🔊 Głośny (Verbose)" };
10
11 writeln!(f, "{} ID: [{}] | {}", Icon::ENTRY, Color::num(&self.id), Color::folder(name))?;
12 writeln!(f, "{} {}", DrawTree::ENTRY_BRANCH, Color::border(desc))?;
13 writeln!(
14 f,
15 "{} 🎯 Cel: {} | ⚙️ Tryb: {} | {}",
16 DrawTree::ITEM_LAST,
17 Color::file(&self.scan.work_path),
18 Color::size(&self.spec.mode),
19 Color::date(quiet_status)
20 )
21 }
22}
23
24impl std::fmt::Display for ConfigManifest {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 if self.job.is_empty() {
27 return write!(f, "{} Brak zdefiniowanych zadań (jobs) w pliku konfiguracyjnym.", Icon::EMPTY);
28 }
29
30 let mut lines = Vec::new();
31 lines.push(format!("{} Zdefiniowane zadania wsadowe (Łącznie: {}):", Icon::H2, self.job.len()));
32 lines.push("░".repeat(80));
33
34 for job in &self.job {
35 lines.push(job.to_string());
36 }
37
38 lines.push("░".repeat(80));
39
40 write!(f, "{}", lines.join("\n"))
41 }
42}