Skip to content

Commit 0139dfe

Browse files
feat: List patches which are compatible with any app (ReVanced#297)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent 7d1c0e6 commit 0139dfe

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/kotlin/app/revanced/cli/command/ListPatchesCommand.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ internal object ListPatchesCommand : Runnable {
4242
)
4343
private var withOptions: Boolean = false
4444

45+
@Option(
46+
names = ["-u", "--with-universal-patches"],
47+
description = ["List patches which are compatible with any app."],
48+
showDefaultValue = ALWAYS
49+
)
50+
private var withUniversalPatches: Boolean = true
51+
4552
@Option(
4653
names = ["-f", "--filter-package-name"], description = ["Filter patches by package name."]
4754
)
@@ -92,11 +99,12 @@ internal object ListPatchesCommand : Runnable {
9299
}
93100
}
94101

95-
fun Patch<*>.anyPackageName(name: String) = compatiblePackages?.any { it.name == name } == true
102+
fun Patch<*>.filterCompatiblePackages(name: String) = compatiblePackages?.any { it.name == name }
103+
?: withUniversalPatches
96104

97105
val patches = PatchBundleLoader.Jar(*patchBundles)
98106

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

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

0 commit comments

Comments
 (0)