Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
feat: List patches which are compatible with any app (#297)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
SandaruKasa and oSumAtrIX authored Nov 3, 2023
1 parent 7d1c0e6 commit 0139dfe
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/kotlin/app/revanced/cli/command/ListPatchesCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ internal object ListPatchesCommand : Runnable {
)
private var withOptions: Boolean = false

@Option(
names = ["-u", "--with-universal-patches"],
description = ["List patches which are compatible with any app."],
showDefaultValue = ALWAYS
)
private var withUniversalPatches: Boolean = true

@Option(
names = ["-f", "--filter-package-name"], description = ["Filter patches by package name."]
)
Expand Down Expand Up @@ -92,11 +99,12 @@ internal object ListPatchesCommand : Runnable {
}
}

fun Patch<*>.anyPackageName(name: String) = compatiblePackages?.any { it.name == name } == true
fun Patch<*>.filterCompatiblePackages(name: String) = compatiblePackages?.any { it.name == name }
?: withUniversalPatches

val patches = PatchBundleLoader.Jar(*patchBundles)

val filtered = packageName?.let { patches.filter { patch -> patch.anyPackageName(it) } } ?: patches
val filtered = packageName?.let { patches.filter { patch -> patch.filterCompatiblePackages(it) } } ?: patches

if (filtered.isNotEmpty()) logger.info(filtered.joinToString("\n\n") { it.buildString() })
}
Expand Down

0 comments on commit 0139dfe

Please sign in to comment.