refactor: pure command

This commit is contained in:
2026-05-30 00:49:59 +02:00
parent 027efa3f83
commit 500252f1e4
+11 -6
View File
@@ -31,7 +31,7 @@ use error::*;
use crate::{ use crate::{
package_manager::{get_system_state, get_unneeded_packages, remove_packages, update_packages}, package_manager::{get_system_state, get_unneeded_packages, remove_packages, update_packages},
world::{World, get_world_location}, world::{Packages, World, get_world_location},
}; };
#[cfg(all(feature = "yay", feature = "paru"))] #[cfg(all(feature = "yay", feature = "paru"))]
@@ -254,6 +254,14 @@ fn main() -> Result<()> {
let world = World::load_from(world_path)?; let world = World::load_from(world_path)?;
let state = get_system_state()?; let state = get_system_state()?;
pure_command(&world, state, all, args.quiet)?
}
}
Ok(())
}
fn pure_command(world: &World, state: Packages, all: bool, quiet: bool) -> Result<()> {
let aditional = { let aditional = {
let mut x = state.exclude(world.get_packages()); let mut x = state.exclude(world.get_packages());
x.ignore = world.get_packages().ignore.clone(); x.ignore = world.get_packages().ignore.clone();
@@ -263,16 +271,13 @@ fn main() -> Result<()> {
}; };
if aditional.is_empty() { if aditional.is_empty() {
if !args.quiet { if !quiet {
println!("No packages to remove."); println!("No packages to remove.");
} }
return Ok(()); return Ok(());
} }
remove_packages(&aditional, all)?; remove_packages(&aditional, all)
}
}
Ok(())
} }
fn root_file_exists(path: &OsStr) -> std::io::Result<bool> { fn root_file_exists(path: &OsStr) -> std::io::Result<bool> {