This commit is contained in:
steven-omaha
2023-01-11 13:50:39 +01:00
parent af8172690a
commit 701eeab9c5
2 changed files with 11 additions and 24 deletions
+6 -2
View File
@@ -34,12 +34,16 @@ impl ToDoPerBackend {
self.0.iter().all(|(_, packages)| packages.is_empty()) self.0.iter().all(|(_, packages)| packages.is_empty())
} }
pub(crate) fn show(&self) { pub(crate) fn show(&self, keyword: Option<&str>) {
for (backend, packages) in self.iter() { for (backend, packages) in self.iter() {
if packages.is_empty() { if packages.is_empty() {
continue; continue;
} }
println!("{}", backend.get_section());
if let Some(kw) = keyword {
println!("Would {kw} the following packages:");
}
println!("[{}]", backend.get_section());
for package in packages { for package in packages {
println!("{package}"); println!("{package}");
} }
+4 -21
View File
@@ -65,7 +65,7 @@ impl Pacdef {
return; return;
} }
to_install.show(); to_install.show("install".into());
if !get_user_confirmation() { if !get_user_confirmation() {
return; return;
@@ -110,15 +110,7 @@ impl Pacdef {
fn show_unmanaged_packages(self) { fn show_unmanaged_packages(self) {
let unmanaged_per_backend = &self.get_unmanaged_packages(); let unmanaged_per_backend = &self.get_unmanaged_packages();
for (backend, packages) in unmanaged_per_backend.iter() { unmanaged_per_backend.show(None);
if packages.is_empty() {
continue;
}
println!("{}", backend.get_section());
for package in packages {
println!(" {package}");
}
}
} }
fn get_unmanaged_packages(self) -> ToDoPerBackend { fn get_unmanaged_packages(self) -> ToDoPerBackend {
@@ -145,22 +137,13 @@ impl Pacdef {
fn clean_packages(self) { fn clean_packages(self) {
let to_remove = self.get_unmanaged_packages(); let to_remove = self.get_unmanaged_packages();
if to_remove.is_empty() { if to_remove.is_empty() {
println!("nothing to do"); println!("nothing to do");
return; return;
} }
println!("Would remove the following packages and their dependencies:"); to_remove.show("remove".into());
for (backend, packages) in to_remove.iter() {
if packages.is_empty() {
continue;
}
println!(" {}", backend.get_section());
for package in packages {
println!(" {package}");
}
}
if !get_user_confirmation() { if !get_user_confirmation() {
return; return;