From e46d85564320f46c6faa54b2d3fa7fca3fa60019 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 22 Sep 2023 02:56:23 +0200 Subject: [PATCH] feat: Add option to warn about patches not being found in supplied patch bundles --- .../app/revanced/cli/command/PatchCommand.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/revanced-cli/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt b/revanced-cli/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt index d34cdbd..8881b6b 100644 --- a/revanced-cli/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt +++ b/revanced-cli/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt @@ -124,6 +124,13 @@ internal object PatchCommand : Runnable { ) private var purge: Boolean = false + @CommandLine.Option( + names = ["-w", "--warn"], + description = ["Warn if a patch can not be found in the supplied patch bundles"], + showDefaultValue = ALWAYS + ) + private var warn: Boolean = false + @CommandLine.Parameters( description = ["APK file to be patched"], arity = "1..1" ) @@ -179,6 +186,16 @@ internal object PatchCommand : Runnable { val patches = PatchBundleLoader.Jar(*patchBundles.toTypedArray()) + // Warn if a patch can not be found in the supplied patch bundles. + if (warn) patches.map { it.name }.toHashSet().let { availableNames -> + arrayOf(*includedPatches, *excludedPatches).filter { name -> + !availableNames.contains(name) + } + }.let { unknownPatches -> + if (unknownPatches.isEmpty()) return@let + logger.warning("Unknown input of patches:\n${unknownPatches.joinToString("\n")}") + } + logger.info("Setting patch options") optionsFile.let {