Yokan / rebuild
Course 1 8624561

AppBootstrap.desktop.kt

composeApp/src/desktopMain/kotlin/eu/friedcutlet/yokan/app/AppBootstrap.desktop.kt

implementation26 lines
1package eu.friedcutlet.yokan.app23import eu.friedcutlet.yokan.services.files.desktopDataRoot4import eu.friedcutlet.yokan.ui.navigation.searchDeepLink5import java.io.File67object DesktopBootstrapState {8    var args: Array<String> = emptyArray()9}1011actual fun platformBootstrapInput(): PlatformBootstrapInput = PlatformBootstrapInput(12    platformName = "Desktop",13    initialDeepLink = desktopLaunchLink(DesktopBootstrapState.args),14    appDataPath = desktopDataRoot.absolutePath,15)1617private val linkSchemes = listOf("yokan://", "tachiyomi://", "mihon://", "aniyomi://", "animetail://", "http://", "https://", "file:")1819/** `--search <query>` / `--search=<query>`, an app link, or a backup file path (file associations pass the path). */20internal fun desktopLaunchLink(args: Array<String>): String? {21    val search = args.indexOf("--search").takeIf { it >= 0 }?.let { args.getOrNull(it + 1) }22        ?: args.firstOrNull { it.startsWith("--search=") }?.removePrefix("--search=")23    if (!search.isNullOrBlank()) return searchDeepLink(search.trim())24    return args.firstOrNull { arg -> linkSchemes.any(arg::startsWith) }25        ?: args.firstOrNull { !it.startsWith("-") && File(it).isFile }?.let { File(it).absoluteFile.toURI().toString() }26}27

Search chapters, reference and source filenames.