refactor: pure command
This commit is contained in:
+22
-17
@@ -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,27 +254,32 @@ 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()?;
|
||||||
|
|
||||||
let aditional = {
|
pure_command(&world, state, all, args.quiet)?
|
||||||
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)?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
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> {
|
fn root_file_exists(path: &OsStr) -> std::io::Result<bool> {
|
||||||
let status = Command::new(PRIVLAGE_ESCELATE_COMMAND)
|
let status = Command::new(PRIVLAGE_ESCELATE_COMMAND)
|
||||||
.arg("test")
|
.arg("test")
|
||||||
|
|||||||
Reference in New Issue
Block a user