diff --git a/example_configs/apt.yaml b/example_configs/system.yaml similarity index 100% rename from example_configs/apt.yaml rename to example_configs/system.yaml diff --git a/src/command.rs b/src/command.rs index 8e98985..5943640 100644 --- a/src/command.rs +++ b/src/command.rs @@ -217,24 +217,32 @@ impl Updater { let mut status: Vec<_> = vec![]; // XXX: We may parallelise (iter_par from rayon?) this loop. But the UI will be problematic to handle - for (_packager_name, packager) in &self.packagers { + for (packager_name, packager) in &self.packagers { // TODO: default status should be an error, but… in the same time we should not have en empty list - let mut stat = (String::from("No command"), Ok(()).into()); + let mut record = Record { + packager: String::from("No packager"), + executor: String::from("No executor"), + status: Ok(()).into(), + }; assert!(!packager.executors.is_empty()); - for pkg in &packager.executors { - let u = self.update(&pkg, opt); + for executor in &packager.executors { + let u = self.update(&executor, opt); let is_ok = u.is_ok(); - stat = (pkg.name.clone(), u.into()); + record = Record { + packager: packager_name.to_string(), + executor: executor.name.clone(), + status: u.into(), + }; if is_ok { break; } } - status.push(stat); + status.push(record); } Summary { status } diff --git a/src/lib.rs b/src/lib.rs index 8976bb6..3d56be4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,18 +21,33 @@ pub struct Opt { pub steps: Vec, } +pub struct Record { + packager: String, + executor: String, + status: Status, +} +impl Display for Record { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "\t{} ({})\t{}", + &self.packager, &self.executor, &self.status + ) + } +} + pub struct Summary { - status: Vec<(String, Status)>, + status: Vec, } impl Display for Summary { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { writeln!(f, "")?; writeln!(f, "*** Summary: ***")?; - for (name, status) in &self.status { + for record in &self.status { // TODO: also print version before/after, update time - writeln!(f, "\t{}\t{}", name, status)?; + writeln!(f, "{record}")?; } Ok(()) }