refactor: pure command

This commit is contained in:
2026-05-30 00:49:59 +02:00
parent 027efa3f83
commit 500252f1e4
+22 -17
View File
@@ -31,7 +31,7 @@ use error::*;
use crate::{
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"))]
@@ -254,27 +254,32 @@ fn main() -> Result<()> {
let world = World::load_from(world_path)?;
let state = get_system_state()?;
let aditional = {
let mut x = state.exclude(world.get_packages());
x.ignore = world.get_packages().ignore.clone();
x.official.extend(get_unneeded_packages()?);
x.exclude_ignored();
x.get_package_list()
};
if aditional.is_empty() {
if !args.quiet {
println!("No packages to remove.");
}
return Ok(());
}
remove_packages(&aditional, all)?;
pure_command(&world, state, all, args.quiet)?
}
}
Ok(())
}
fn pure_command(world: &World, state: Packages, all: bool, quiet: bool) -> Result<()> {
let aditional = {
let mut x = state.exclude(world.get_packages());
x.ignore = world.get_packages().ignore.clone();
x.official.extend(get_unneeded_packages()?);
x.exclude_ignored();
x.get_package_list()
};
if aditional.is_empty() {
if !quiet {
println!("No packages to remove.");
}
return Ok(());
}
remove_packages(&aditional, all)
}
fn root_file_exists(path: &OsStr) -> std::io::Result<bool> {
let status = Command::new(PRIVLAGE_ESCELATE_COMMAND)
.arg("test")