mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-19 17:33:57 +00:00
feat: Allow selecting first Adb device, if none supplied automatically by updating dependencies
This commit is contained in:
@@ -5,24 +5,23 @@ import picocli.CommandLine.*
|
||||
import java.io.File
|
||||
import java.util.logging.Logger
|
||||
|
||||
|
||||
@Command(
|
||||
name = "install",
|
||||
description = ["Install an APK file to devices with the supplied ADB device serials"]
|
||||
description = ["Install an APK file to devices with the supplied ADB device serials"],
|
||||
)
|
||||
internal object InstallCommand : Runnable {
|
||||
private val logger = Logger.getLogger(InstallCommand::class.java.name)
|
||||
|
||||
@Parameters(
|
||||
description = ["ADB device serials"],
|
||||
arity = "1..*"
|
||||
description = ["ADB device serials. If not supplied, the first connected device will be used."],
|
||||
arity = "0..*",
|
||||
)
|
||||
private lateinit var deviceSerials: Array<String>
|
||||
private var deviceSerials: Array<String>? = null
|
||||
|
||||
@Option(
|
||||
names = ["-a", "--apk"],
|
||||
description = ["APK file to be installed"],
|
||||
required = true
|
||||
required = true,
|
||||
)
|
||||
private lateinit var apk: File
|
||||
|
||||
@@ -32,11 +31,13 @@ internal object InstallCommand : Runnable {
|
||||
)
|
||||
private var packageName: String? = null
|
||||
|
||||
override fun run() = deviceSerials.forEach { deviceSerial ->
|
||||
try {
|
||||
override fun run() {
|
||||
fun install(deviceSerial: String? = null) = try {
|
||||
AdbManager.getAdbManager(deviceSerial, packageName != null).install(AdbManager.Apk(apk, packageName))
|
||||
} catch (e: AdbManager.DeviceNotFoundException) {
|
||||
logger.severe(e.toString())
|
||||
}
|
||||
|
||||
deviceSerials?.forEach(::install) ?: install()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user