mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-11 13:56:18 +00:00
feat: List patches which are compatible with any app (#297)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
@@ -42,6 +42,13 @@ internal object ListPatchesCommand : Runnable {
|
|||||||
)
|
)
|
||||||
private var withOptions: Boolean = false
|
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(
|
@Option(
|
||||||
names = ["-f", "--filter-package-name"], description = ["Filter patches by package name."]
|
names = ["-f", "--filter-package-name"], description = ["Filter patches by package name."]
|
||||||
)
|
)
|
||||||
@@ -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 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() })
|
if (filtered.isNotEmpty()) logger.info(filtered.joinToString("\n\n") { it.buildString() })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user