feat: pure before sync

Added arg that will cause to run
pure subcommand before sync.
This commit is contained in:
2026-05-30 01:10:12 +02:00
parent 328bb207e7
commit 8c83e733c2
+12 -3
View File
@@ -65,7 +65,13 @@ struct Args {
#[derive(Debug, Clone, Copy, Subcommand)] #[derive(Debug, Clone, Copy, Subcommand)]
enum Commands { enum Commands {
/// Synchronizes state of machine with the world file and update everythink /// Synchronizes state of machine with the world file and update everythink
Sync, Sync {
#[arg(short = 'r', long)]
pure: bool,
#[arg(short = 'a', long)]
pure_all: bool,
},
/// Export currently installed packages to the world file /// Export currently installed packages to the world file
Export { Export {
#[arg(short, long)] #[arg(short, long)]
@@ -99,11 +105,15 @@ fn main() -> Result<()> {
}; };
match args.command { match args.command {
Commands::Sync => { Commands::Sync { pure, pure_all } => {
let world = World::load_from(world_path)?; let world = World::load_from(world_path)?;
let world_state = world.get_packages(); let world_state = world.get_packages();
let state = get_system_state()?; let state = get_system_state()?;
if pure {
pure_command(&world, state.clone(), pure_all, args.quiet)?;
}
let not_installed = { let not_installed = {
let mut x = world_state.exclude(&state); let mut x = world_state.exclude(&state);
x.ignore = world_state.ignore.clone(); x.ignore = world_state.ignore.clone();
@@ -261,7 +271,6 @@ fn main() -> Result<()> {
} }
fn pure_command(world: &World, state: Packages, all: bool, quiet: bool) -> Result<()> { 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();