mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-06-02 11:26:06 +02:00
improve consistency
This commit is contained in:
parent
cac4e587d4
commit
5916adb217
|
@ -42,18 +42,18 @@ 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."]
|
||||
)
|
||||
private var packageName: String? = null
|
||||
|
||||
@Option(
|
||||
names = ["--filter-include-packageless"],
|
||||
description = ["Include patches with no compatible packages listed when filtering by package name."],
|
||||
showDefaultValue = ALWAYS
|
||||
)
|
||||
private var patchesWithNoPackage: Boolean = false
|
||||
|
||||
override fun run() {
|
||||
fun Patch.CompatiblePackage.buildString() = buildString {
|
||||
if (withVersions && versions != null) {
|
||||
|
@ -99,11 +99,12 @@ internal object ListPatchesCommand : Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
fun Patch<*>.anyPackageName(name: String) = compatiblePackages?.any { it.name == name } ?: patchesWithNoPackage
|
||||
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() })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user