mirror of
https://github.com/revanced/revanced-cli.git
synced 2025-04-30 06:34:29 +02:00
fix: Group mount
and install
options into an argument group (#364)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
a0189aeaee
commit
0c53a2d1d7
@ -115,21 +115,27 @@ internal object PatchCommand : Runnable {
|
|||||||
this.outputFilePath = outputFilePath?.absoluteFile
|
this.outputFilePath = outputFilePath?.absoluteFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ArgGroup(exclusive = false, multiplicity = "0..1")
|
||||||
|
internal var installation: Installation? = null
|
||||||
|
|
||||||
|
internal class Installation {
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["-i", "--install"],
|
names = ["-i", "--install"],
|
||||||
|
required = true,
|
||||||
description = ["Serial of the ADB device to install to. If not specified, the first connected device will be used."],
|
description = ["Serial of the ADB device to install to. If not specified, the first connected device will be used."],
|
||||||
// Empty string to indicate that the first connected device should be used.
|
fallbackValue = "", // Empty string is used to select the first of connected devices.
|
||||||
fallbackValue = "",
|
|
||||||
arity = "0..1",
|
arity = "0..1",
|
||||||
)
|
)
|
||||||
private var deviceSerial: String? = null
|
internal var deviceSerial: String? = null
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["--mount"],
|
names = ["--mount"],
|
||||||
|
required = false,
|
||||||
description = ["Install the patched APK file by mounting."],
|
description = ["Install the patched APK file by mounting."],
|
||||||
showDefaultValue = ALWAYS,
|
showDefaultValue = ALWAYS,
|
||||||
)
|
)
|
||||||
private var mount: Boolean = false
|
internal var mount: Boolean = false
|
||||||
|
}
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["--keystore"],
|
names = ["--keystore"],
|
||||||
@ -245,11 +251,11 @@ internal object PatchCommand : Runnable {
|
|||||||
keyStoreFilePath ?: outputFilePath.parentFile
|
keyStoreFilePath ?: outputFilePath.parentFile
|
||||||
.resolve("${outputFilePath.nameWithoutExtension}.keystore")
|
.resolve("${outputFilePath.nameWithoutExtension}.keystore")
|
||||||
|
|
||||||
val installer = if (deviceSerial != null) {
|
val installer = if (installation?.deviceSerial != null) {
|
||||||
val deviceSerial = deviceSerial!!.ifEmpty { null }
|
val deviceSerial = installation?.deviceSerial!!.ifEmpty { null }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mount) {
|
if (installation?.mount == true) {
|
||||||
AdbRootInstaller(deviceSerial)
|
AdbRootInstaller(deviceSerial)
|
||||||
} else {
|
} else {
|
||||||
AdbInstaller(deviceSerial)
|
AdbInstaller(deviceSerial)
|
||||||
@ -332,7 +338,7 @@ internal object PatchCommand : Runnable {
|
|||||||
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply {
|
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply {
|
||||||
patcherResult.applyTo(this)
|
patcherResult.applyTo(this)
|
||||||
}.let { patchedApkFile ->
|
}.let { patchedApkFile ->
|
||||||
if (!mount) {
|
if (installation?.mount != true) {
|
||||||
ApkUtils.signApk(
|
ApkUtils.signApk(
|
||||||
patchedApkFile,
|
patchedApkFile,
|
||||||
outputFilePath,
|
outputFilePath,
|
||||||
@ -355,7 +361,7 @@ internal object PatchCommand : Runnable {
|
|||||||
|
|
||||||
// region Install.
|
// region Install.
|
||||||
|
|
||||||
deviceSerial?.let {
|
installation?.deviceSerial?.let {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
when (val result = installer!!.install(Installer.Apk(outputFilePath, packageName))) {
|
when (val result = installer!!.install(Installer.Apk(outputFilePath, packageName))) {
|
||||||
RootInstallerResult.FAILURE -> logger.severe("Failed to mount the patched APK file")
|
RootInstallerResult.FAILURE -> logger.severe("Failed to mount the patched APK file")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user