Show packager and executor in summary
This commit is contained in:
		@@ -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 }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/lib.rs
									
									
									
									
									
								
							@@ -21,18 +21,33 @@ pub struct Opt {
 | 
			
		||||
    pub steps: Vec<UpdateSteps>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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<Record>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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(())
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user