fix: deploy to adb

Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
oSumAtrIX
2022-05-06 03:00:02 +02:00
parent 3776ab9a0b
commit f9b987e858
4 changed files with 103 additions and 60 deletions

View File

@@ -2,7 +2,7 @@ package app.revanced.cli
import app.revanced.patch.PatchLoader
import app.revanced.patch.Patches
import picocli.CommandLine
import app.revanced.utils.adb.Adb
import picocli.CommandLine.*
import java.io.File
@@ -10,24 +10,26 @@ import java.io.File
name = "ReVanced-CLI", version = ["1.0.0"], mixinStandardHelpOptions = true
)
internal object MainCommand : Runnable {
@Option(names = ["-p", "--patches"], description = ["One or more bundles of patches"])
internal var patchBundles = arrayOf<File>()
@Parameters(
paramLabel = "INCLUDE",
description = ["Which patches to include. If none is specified, all compatible patches will be included"]
)
internal var includedPatches = arrayOf<String>()
@Option(names = ["-c", "--cache"], description = ["Output resource cache directory"], required = true)
@Option(names = ["-p", "--patches"], description = ["One or more bundles of patches"])
internal var patchBundles = arrayOf<File>()
@Option(names = ["-t", "--temp-dir"], description = ["Temporal resource cache directory"], required = true)
internal lateinit var cacheDirectory: String
@Option(names = ["-r", "--resource-patcher"], description = ["Enable patching resources"])
internal var patchResources: Boolean = false
@Option(names = ["-w", "--wipe-after"], description = ["Wipe the temporal directory before exiting the patcher"])
internal var wipe: Boolean = false
@Option(
names = ["-c", "--clean"],
description = ["Clean the temporal resource cache directory. This will be done anyways when running the patcher"]
)
internal var clean: Boolean = false
@Option(names = ["-l", "--list"], description = ["List patches only"])
internal var listOnly: Boolean = false
@@ -44,7 +46,6 @@ internal object MainCommand : Runnable {
@Option(names = ["-d", "--deploy-on"], description = ["If specified, deploy to adb device with given name"])
internal var deploy: String? = null
override fun run() {
if (listOnly) {
patchBundles.forEach {
@@ -61,17 +62,23 @@ internal object MainCommand : Runnable {
cacheDirectory,
patchResources
)
Patcher.start(patcher)
if (!wipe) return
File(cacheDirectory).deleteRecursively()
if (clean) {
File(cacheDirectory).deleteRecursively()
}
val outputFile = File(outputPath)
deploy?.let {
Adb(
File(outputPath),
outputFile,
patcher.packageName,
deploy!!
).deploy()
}
if (clean) outputFile.delete()
}
}