Skip to content

Commit

Permalink
feat(subcmd/clean): add --keep-installed
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Feb 17, 2025
1 parent 3fee7c6 commit e1b69fe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/subcommand/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub struct Clean {
/// Keep downloadable and installed packages
#[arg(long, conflicts_with = "keep_downloadable")]
keep_downloadable_and_installed: bool,
/// Keep installed packages
#[arg(long, conflicts_with = "keep_downloadable_and_installed")]
keep_installed: bool,
/// Set sysroot target directory
#[arg(from_global)]
sysroot: PathBuf,
Expand All @@ -39,6 +42,7 @@ impl CliExecuter for Clean {
dry_run,
keep_downloadable,
keep_downloadable_and_installed,
keep_installed,
} = self;

if dry_run {
Expand Down Expand Up @@ -69,8 +73,9 @@ impl CliExecuter for Clean {
.flatten()
.filter(|x| x.path().extension().is_some_and(|name| name == "deb"))
{
if !keep_downloadable && !keep_downloadable_and_installed {
if !keep_downloadable && !keep_downloadable_and_installed && !keep_installed {
remove_deb(&i);
continue;
}

let file_name = i.file_name();
Expand Down Expand Up @@ -106,7 +111,9 @@ impl CliExecuter for Clean {
continue;
}

if !version.is_downloadable() && keep_downloadable {
if (!version.is_downloadable() && keep_downloadable)
|| (!version.is_installed() && keep_installed)
{
remove_deb(&i);
continue;
}
Expand Down

0 comments on commit e1b69fe

Please sign in to comment.