mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-04 17:32:53 +01:00
fix: make cli compatible with breaking changes of the patcher
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
9fc2f9602a
commit
555b38f386
@ -3,8 +3,8 @@ package app.revanced.cli
|
|||||||
import app.revanced.cli.utils.PatchLoader
|
import app.revanced.cli.utils.PatchLoader
|
||||||
import app.revanced.cli.utils.Patches
|
import app.revanced.cli.utils.Patches
|
||||||
import app.revanced.cli.utils.Preconditions
|
import app.revanced.cli.utils.Preconditions
|
||||||
import app.revanced.cli.utils.SignatureParser
|
|
||||||
import app.revanced.patcher.Patcher
|
import app.revanced.patcher.Patcher
|
||||||
|
import app.revanced.patcher.patch.PatchMetadata
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import kotlinx.cli.ArgParser
|
import kotlinx.cli.ArgParser
|
||||||
import kotlinx.cli.ArgType
|
import kotlinx.cli.ArgType
|
||||||
@ -21,7 +21,6 @@ class Main {
|
|||||||
companion object {
|
companion object {
|
||||||
private fun runCLI(
|
private fun runCLI(
|
||||||
inApk: String,
|
inApk: String,
|
||||||
inSignatures: String,
|
|
||||||
inPatches: String,
|
inPatches: String,
|
||||||
inIntegrations: String?,
|
inIntegrations: String?,
|
||||||
inOutput: String,
|
inOutput: String,
|
||||||
@ -35,21 +34,19 @@ class Main {
|
|||||||
.maxHint(1)
|
.maxHint(1)
|
||||||
.setExtraMessage("Initializing")
|
.setExtraMessage("Initializing")
|
||||||
val apk = Preconditions.isFile(inApk)
|
val apk = Preconditions.isFile(inApk)
|
||||||
val signatures = Preconditions.isFile(inSignatures)
|
|
||||||
val patchesFile = Preconditions.isFile(inPatches)
|
val patchesFile = Preconditions.isFile(inPatches)
|
||||||
val output = Preconditions.isDirectory(inOutput)
|
val output = Preconditions.isDirectory(inOutput)
|
||||||
bar.step()
|
bar.step()
|
||||||
|
|
||||||
val patcher = Patcher(
|
val patcher = Patcher(
|
||||||
apk,
|
apk,
|
||||||
SignatureParser.parse(signatures.readText(), bar)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
inIntegrations?.let {
|
inIntegrations?.let {
|
||||||
bar.reset().maxHint(1)
|
bar.reset().maxHint(1)
|
||||||
.extraMessage = "Merging integrations"
|
.extraMessage = "Merging integrations"
|
||||||
val integrations = Preconditions.isFile(it)
|
val integrations = Preconditions.isFile(it)
|
||||||
patcher.addFiles(listOf(integrations))
|
//patcher.addFiles(listOf(integrations))
|
||||||
bar.step()
|
bar.step()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,12 +80,12 @@ class Main {
|
|||||||
printResults(results)
|
printResults(results)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun printResults(results: Map<String, Result<PatchResult>>) {
|
private fun printResults(results: Map<PatchMetadata, Result<PatchResult>>) {
|
||||||
for ((name, result) in results) {
|
for ((metadata, result) in results) {
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
println("Patch $name was applied successfully!")
|
println("${metadata.name} was applied successfully!")
|
||||||
} else {
|
} else {
|
||||||
println("Patch $name failed to apply! Cause:")
|
println("${metadata.name} failed to apply! Cause:")
|
||||||
result.exceptionOrNull()!!.printStackTrace()
|
result.exceptionOrNull()!!.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,12 +102,6 @@ class Main {
|
|||||||
shortName = "a",
|
shortName = "a",
|
||||||
description = "APK file"
|
description = "APK file"
|
||||||
).required()
|
).required()
|
||||||
val signatures by parser.option(
|
|
||||||
ArgType.String,
|
|
||||||
fullName = "signatures",
|
|
||||||
shortName = "s",
|
|
||||||
description = "Signatures JSON file"
|
|
||||||
).required()
|
|
||||||
val patches by parser.option(
|
val patches by parser.option(
|
||||||
ArgType.String,
|
ArgType.String,
|
||||||
fullName = "patches",
|
fullName = "patches",
|
||||||
@ -133,7 +124,6 @@ class Main {
|
|||||||
parser.parse(args)
|
parser.parse(args)
|
||||||
runCLI(
|
runCLI(
|
||||||
apk,
|
apk,
|
||||||
signatures,
|
|
||||||
patches,
|
patches,
|
||||||
integrations,
|
integrations,
|
||||||
output,
|
output,
|
||||||
|
Loading…
Reference in New Issue
Block a user