mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-11-03 18:33:55 +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
|
||||
|
||||
@Option(
|
||||
names = ["-f", "--filter-package-name"], description = ["Filter patches by package name"]
|
||||
)
|
||||
private var packageName: String? = null
|
||||
|
||||
override fun run() {
|
||||
fun Patch.CompatiblePackage.buildString() = buildString {
|
||||
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
|
||||
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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user