refactor
This commit is contained in:
@@ -34,14 +34,18 @@ 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
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user