mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-24 19:15:48 +01:00
feat: Add option to filter patches to be listed by package name
This commit is contained in:
parent
77d91735ff
commit
50c0f98ce5
@ -42,6 +42,11 @@ internal object ListPatchesCommand : Runnable {
|
|||||||
)
|
)
|
||||||
private var withOptions: Boolean = false
|
private var withOptions: Boolean = false
|
||||||
|
|
||||||
|
@Option(
|
||||||
|
names = ["-f", "--filter-package-name"], description = ["Filter patches by package name"]
|
||||||
|
)
|
||||||
|
private var packageName: String? = null
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
fun Patch.CompatiblePackage.buildString() = buildString {
|
fun Patch.CompatiblePackage.buildString() = buildString {
|
||||||
if (withVersions && versions != null) {
|
if (withVersions && versions != null) {
|
||||||
@ -83,6 +88,12 @@ internal object ListPatchesCommand : Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(PatchBundleLoader.Jar(*patchBundles).joinToString("\n\n") { it.buildString() })
|
fun Patch<*>.anyPackageName(name: String) = compatiblePackages?.any { it.name == name } == true
|
||||||
|
|
||||||
|
val patches = PatchBundleLoader.Jar(*patchBundles)
|
||||||
|
|
||||||
|
val filtered = packageName?.let { patches.filter { patch -> patch.anyPackageName(it) } } ?: patches
|
||||||
|
|
||||||
|
if (filtered.isNotEmpty()) logger.info(filtered.joinToString("\n\n") { it.buildString() })
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ internal object PatchUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `return null because no patch is compatible with the supplied package name`() {
|
fun `return null because no patch is compatible with the supplied package name`() {
|
||||||
val patches = setOf(newPatch("other.package", "a"))
|
val patches = setOf(newPatch("some.package", "a"))
|
||||||
|
|
||||||
assertEqualsVersion(null, patches, "other.package")
|
assertEqualsVersion(null, patches, "other.package")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user