@@ -7,6 +7,7 @@ import kotlinx.coroutines.runBlocking
77import picocli.CommandLine.*
88import java.io.File
99import java.util.logging.Logger
10+ import kotlin.system.exitProcess
1011
1112@Command(
1213 name = " install" ,
@@ -30,7 +31,7 @@ internal object InstallCommand : Runnable {
3031
3132 @Option(
3233 names = [" -m" , " --mount" ],
33- description = [" Mount the supplied APK file over the app with the supplied package name." ],
34+ description = [" Mount the supplied APK file over the app with the given package name." ],
3435 )
3536 private var packageName: String? = null
3637
@@ -44,24 +45,35 @@ internal object InstallCommand : Runnable {
4445 }.install(Installer .Apk (apk, packageName))
4546 } catch (e: Exception ) {
4647 logger.severe(e.toString())
47- return
48+ throw e
4849 }
4950
5051 when (result) {
5152 RootInstallerResult .SUCCESS ->
5253 logger.info(" Mounted the APK file" )
53- RootInstallerResult .FAILURE ->
54+ RootInstallerResult .FAILURE -> {
5455 logger.severe(" Failed to mount the APK file" )
56+ throw Exception ()
57+ }
5558 AdbInstallerResult .Success ->
5659 logger.info(" Installed the APK file" )
57- is AdbInstallerResult .Failure ->
60+ is AdbInstallerResult .Failure -> {
5861 logger.severe(result.exception.toString())
59- else -> logger.severe(" Unknown installation result" )
62+ throw Exception ()
63+ }
64+ else -> {
65+ logger.severe(" Unknown installation result" )
66+ throw Exception ()
67+ }
6068 }
6169 }
6270
6371 runBlocking {
64- deviceSerials?.map { async { install(it) } }?.awaitAll() ? : install()
72+ try {
73+ deviceSerials?.map { async { install(it) } }?.awaitAll() ? : install()
74+ } catch (_: Exception ) {
75+ exitProcess(1 )
76+ }
6577 }
6678 }
6779}
0 commit comments