From 5db85c7fb924020fb92a5d373aeb059ac3aa2f6e Mon Sep 17 00:00:00 2001 From: Prateek <129204458+prateek-who@users.noreply.github.com> Date: Sat, 21 Feb 2026 15:27:37 +0530 Subject: [PATCH 1/8] --out and --patches support Added --out and -- patches flag for list-command. --- .../morphe/cli/command/ListPatchesCommand.kt | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index 1f1f226..df781d9 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -3,7 +3,8 @@ package app.morphe.cli.command import app.morphe.patcher.patch.Package import app.morphe.patcher.patch.Patch import app.morphe.patcher.patch.loadPatchesFromJar -import picocli.CommandLine.* +import picocli.CommandLine.Command +import picocli.CommandLine.Option import picocli.CommandLine.Help.Visibility.ALWAYS import java.io.File import java.util.logging.Logger @@ -16,11 +17,19 @@ import app.morphe.patcher.patch.Option as PatchOption internal object ListPatchesCommand : Runnable { private val logger = Logger.getLogger(this::class.java.name) - @Parameters( - description = ["Paths to MPP files."], + // Patches is not flag based rather than position based + @Option( + names = ["--patches"], + description = ["One or more paths to MPP files."], arity = "1..*", ) - private lateinit var patchesFiles: Set + private var patchFiles: Set? = null + + @Option( + names = ["--out"], + description = ["Path to the output text file."], + ) + private var outputFile: File? = null @Option( names = ["-d", "--with-descriptions"], @@ -138,11 +147,28 @@ internal object ListPatchesCommand : Runnable { compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name } ?: withUniversalPatches - val patches = loadPatchesFromJar(patchesFiles).withIndex().toList() + if (patchFiles.isNullOrEmpty()) return logger.warning("No patch file passed. Please add a patch file.") + + // We are using !! here because we already have a guard above that returns if the value is null or empty. + val patches = loadPatchesFromJar(patchFiles!!).withIndex().toList() val filtered = packageName?.let { patches.filter { (_, patch) -> patch.filterCompatiblePackages(it) } } ?: patches - if (filtered.isNotEmpty()) logger.info(filtered.joinToString("\n\n") { it.buildString() }) + // Extracted the final output that we get into this variable. Now we just call this based + // on what the user wants. In the console or as an external text file. + val finalOutput = filtered.joinToString("\n\n") {it.buildString()} + + + if (filtered.isNotEmpty()) { + if (outputFile == null) { + logger.info(finalOutput) + } else if (outputFile != null) { + logger.info("Created new output file at ${outputFile?.path}") + outputFile?.writeText(finalOutput) + } + } + + } } From 266ad977f68efa135959c123ba674d3317757a15 Mon Sep 17 00:00:00 2001 From: Prateek <129204458+prateek-who@users.noreply.github.com> Date: Sat, 21 Feb 2026 15:30:21 +0530 Subject: [PATCH 2/8] Update ListPatchesCommand.kt --- src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index df781d9..37da6dd 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -17,7 +17,7 @@ import app.morphe.patcher.patch.Option as PatchOption internal object ListPatchesCommand : Runnable { private val logger = Logger.getLogger(this::class.java.name) - // Patches is not flag based rather than position based + // Patches is now flag based rather than position based @Option( names = ["--patches"], description = ["One or more paths to MPP files."], From 5a5447ee7a9977612598070e781a8f777f7b42cf Mon Sep 17 00:00:00 2001 From: Prateek <129204458+prateek-who@users.noreply.github.com> Date: Sat, 21 Feb 2026 15:27:37 +0530 Subject: [PATCH 3/8] --out and --patches support Added --out and -- patches flag for list-command. --- .../morphe/cli/command/ListPatchesCommand.kt | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index 1f1f226..df781d9 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -3,7 +3,8 @@ package app.morphe.cli.command import app.morphe.patcher.patch.Package import app.morphe.patcher.patch.Patch import app.morphe.patcher.patch.loadPatchesFromJar -import picocli.CommandLine.* +import picocli.CommandLine.Command +import picocli.CommandLine.Option import picocli.CommandLine.Help.Visibility.ALWAYS import java.io.File import java.util.logging.Logger @@ -16,11 +17,19 @@ import app.morphe.patcher.patch.Option as PatchOption internal object ListPatchesCommand : Runnable { private val logger = Logger.getLogger(this::class.java.name) - @Parameters( - description = ["Paths to MPP files."], + // Patches is not flag based rather than position based + @Option( + names = ["--patches"], + description = ["One or more paths to MPP files."], arity = "1..*", ) - private lateinit var patchesFiles: Set + private var patchFiles: Set? = null + + @Option( + names = ["--out"], + description = ["Path to the output text file."], + ) + private var outputFile: File? = null @Option( names = ["-d", "--with-descriptions"], @@ -138,11 +147,28 @@ internal object ListPatchesCommand : Runnable { compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name } ?: withUniversalPatches - val patches = loadPatchesFromJar(patchesFiles).withIndex().toList() + if (patchFiles.isNullOrEmpty()) return logger.warning("No patch file passed. Please add a patch file.") + + // We are using !! here because we already have a guard above that returns if the value is null or empty. + val patches = loadPatchesFromJar(patchFiles!!).withIndex().toList() val filtered = packageName?.let { patches.filter { (_, patch) -> patch.filterCompatiblePackages(it) } } ?: patches - if (filtered.isNotEmpty()) logger.info(filtered.joinToString("\n\n") { it.buildString() }) + // Extracted the final output that we get into this variable. Now we just call this based + // on what the user wants. In the console or as an external text file. + val finalOutput = filtered.joinToString("\n\n") {it.buildString()} + + + if (filtered.isNotEmpty()) { + if (outputFile == null) { + logger.info(finalOutput) + } else if (outputFile != null) { + logger.info("Created new output file at ${outputFile?.path}") + outputFile?.writeText(finalOutput) + } + } + + } } From 51ca317641bc7c67dbff880ac8dbc24bd2a135eb Mon Sep 17 00:00:00 2001 From: Prateek <129204458+prateek-who@users.noreply.github.com> Date: Sat, 21 Feb 2026 15:30:21 +0530 Subject: [PATCH 4/8] Update ListPatchesCommand.kt --- src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index df781d9..37da6dd 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -17,7 +17,7 @@ import app.morphe.patcher.patch.Option as PatchOption internal object ListPatchesCommand : Runnable { private val logger = Logger.getLogger(this::class.java.name) - // Patches is not flag based rather than position based + // Patches is now flag based rather than position based @Option( names = ["--patches"], description = ["One or more paths to MPP files."], From ec25d1a1499918769ed529093f119a2a7e037588 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 22 Feb 2026 08:44:50 +0100 Subject: [PATCH 5/8] Adjust console message --- .../app/morphe/cli/command/ListPatchesCommand.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index 37da6dd..eeac949 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -1,3 +1,11 @@ +/* + * Copyright 2026 Morphe. + * https://github.com/MorpheApp/morphe-cli + * + * Original hard forked code: + * https://github.com/revanced/revanced-cli + */ + package app.morphe.cli.command import app.morphe.patcher.patch.Package @@ -147,7 +155,7 @@ internal object ListPatchesCommand : Runnable { compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name } ?: withUniversalPatches - if (patchFiles.isNullOrEmpty()) return logger.warning("No patch file passed. Please add a patch file.") + if (patchFiles.isNullOrEmpty()) return logger.warning("No patch file provided. Please specify one or more mpp files using --patches") // We are using !! here because we already have a guard above that returns if the value is null or empty. val patches = loadPatchesFromJar(patchFiles!!).withIndex().toList() From d7ffda8b5fb42c6f34cdc99641d4389cd9b0f40d Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 22 Feb 2026 08:57:21 +0100 Subject: [PATCH 6/8] refactor: no functional changes --- .../morphe/cli/command/ListPatchesCommand.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index eeac949..44a6736 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -157,26 +157,27 @@ internal object ListPatchesCommand : Runnable { if (patchFiles.isNullOrEmpty()) return logger.warning("No patch file provided. Please specify one or more mpp files using --patches") - // We are using !! here because we already have a guard above that returns if the value is null or empty. val patches = loadPatchesFromJar(patchFiles!!).withIndex().toList() - val filtered = - packageName?.let { patches.filter { (_, patch) -> patch.filterCompatiblePackages(it) } } ?: patches + val filtered = packageName?.let { + patches.filter { (_, patch) -> + patch.filterCompatiblePackages( + it + ) + } + } ?: patches // Extracted the final output that we get into this variable. Now we just call this based // on what the user wants. In the console or as an external text file. val finalOutput = filtered.joinToString("\n\n") {it.buildString()} - if (filtered.isNotEmpty()) { if (outputFile == null) { logger.info(finalOutput) - } else if (outputFile != null) { - logger.info("Created new output file at ${outputFile?.path}") - outputFile?.writeText(finalOutput) + } else { + logger.info("Created new output file at ${outputFile!!.path}") + outputFile!!.writeText(finalOutput) } } - - } } From 75f5a4b1af0671916d86075752ac3b3e7c0f9508 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 22 Feb 2026 09:00:10 +0100 Subject: [PATCH 7/8] Log no patches exist --- src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index 44a6736..09ff3e4 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -171,7 +171,9 @@ internal object ListPatchesCommand : Runnable { // on what the user wants. In the console or as an external text file. val finalOutput = filtered.joinToString("\n\n") {it.buildString()} - if (filtered.isNotEmpty()) { + if (filtered.isEmpty()) { + logger.warning("No compatible patches found in: $patchFiles") + } else { if (outputFile == null) { logger.info(finalOutput) } else { From 846461a72d677022484b9a556e5ff53198a77fb3 Mon Sep 17 00:00:00 2001 From: Prateek <129204458+prateek-who@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:25:36 +0530 Subject: [PATCH 8/8] Update ListPatchesCommand.kt --- .../app/morphe/cli/command/ListPatchesCommand.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt index 09ff3e4..05ef74b 100644 --- a/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt +++ b/src/main/kotlin/app/morphe/cli/command/ListPatchesCommand.kt @@ -30,12 +30,13 @@ internal object ListPatchesCommand : Runnable { names = ["--patches"], description = ["One or more paths to MPP files."], arity = "1..*", + required = true ) - private var patchFiles: Set? = null + private lateinit var patchFiles: Set @Option( names = ["--out"], - description = ["Path to the output text file."], + description = ["Path to the output text file. Writes patch list to this file instead of stdout."], ) private var outputFile: File? = null @@ -152,12 +153,11 @@ internal object ListPatchesCommand : Runnable { } fun Patch<*>.filterCompatiblePackages(name: String) = - compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name } - ?: withUniversalPatches + compatiblePackages?.any { (compatiblePackageName, _) -> + compatiblePackageName == name + } ?: withUniversalPatches - if (patchFiles.isNullOrEmpty()) return logger.warning("No patch file provided. Please specify one or more mpp files using --patches") - - val patches = loadPatchesFromJar(patchFiles!!).withIndex().toList() + val patches = loadPatchesFromJar(patchFiles).withIndex().toList() val filtered = packageName?.let { patches.filter { (_, patch) ->