From b41fe1a4e14fe65252ec14d213e86efd16755521 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Mon, 12 Aug 2024 21:39:26 -0400 Subject: [PATCH] Add --launch and --electron --- src/main/kotlin/suwayomi/tachidesk/launcher/Main.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/suwayomi/tachidesk/launcher/Main.kt b/src/main/kotlin/suwayomi/tachidesk/launcher/Main.kt index f2c3dfe..70fc983 100644 --- a/src/main/kotlin/suwayomi/tachidesk/launcher/Main.kt +++ b/src/main/kotlin/suwayomi/tachidesk/launcher/Main.kt @@ -14,6 +14,7 @@ import com.github.weisj.darklaf.theme.event.ThemeChangeEvent import com.github.weisj.darklaf.theme.event.ThemeChangeListener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.MainScope +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -46,7 +47,7 @@ import javax.swing.JFrame import javax.swing.JOptionPane import kotlin.system.exitProcess -suspend fun main() { +suspend fun main(args: Array) { Thread.setDefaultUncaughtExceptionHandler { _, e -> val option = JOptionPane.showOptionDialog( null, @@ -74,6 +75,12 @@ suspend fun main() { val scope = MainScope() val vm = LauncherViewModel() + if (args.contains("--launch")) { + vm.launch(forceElectron = args.contains("--electron")) + delay(Long.MAX_VALUE) + return + } + withContext(Dispatchers.Swing.immediate) { setupTheme(vm)