From 7c2c0376542bb7efb08184122f9159e075ce9b6f Mon Sep 17 00:00:00 2001 From: Koitharu Date: Fri, 18 Oct 2024 09:04:17 +0300 Subject: [PATCH] Update parsers --- build.gradle.kts | 2 +- src/main/kotlin/org/koitharu/kotatsu/dl/Main.kt | 12 ++++-------- .../org/koitharu/kotatsu/dl/util/AppCommand.kt | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e71b898..71aa1e6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,7 +31,7 @@ dependencies { testImplementation(kotlin("test")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.9.0") implementation("com.github.ajalt.clikt:clikt-core:5.0.1") - implementation("com.github.KotatsuApp:kotatsu-parsers:481fb4f0d0") + implementation("com.github.KotatsuApp:kotatsu-parsers:08fe54c36d") implementation("com.squareup.okhttp3:okhttp:4.12.0") implementation("com.squareup.okio:okio:3.9.0") implementation("io.webfolder:quickjs:1.1.0") diff --git a/src/main/kotlin/org/koitharu/kotatsu/dl/Main.kt b/src/main/kotlin/org/koitharu/kotatsu/dl/Main.kt index cc9e601..c9f8e9c 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/dl/Main.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/dl/Main.kt @@ -1,7 +1,6 @@ package org.koitharu.kotatsu.dl import com.github.ajalt.clikt.command.main -import com.github.ajalt.clikt.core.ProgramResult import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.options.* import com.github.ajalt.clikt.parameters.types.enum @@ -68,10 +67,10 @@ class Main : AppCommand(name = "kotatsu-dl") { val linkResolver = context.newLinkResolver(link) print("Resolving link…") val source = linkResolver.getSource() + val manga = linkResolver.getManga() if (source == null) { println() - System.err.println("Unsupported manga source") - return 1 + error("Unsupported manga source") } println('\r') colored { @@ -79,10 +78,8 @@ class Main : AppCommand(name = "kotatsu-dl") { print(source.title.bold) println() } - val manga = linkResolver.getManga() if (manga == null) { - System.err.println("Manga not found") - return 1 + error("Manga not found") } colored { print("Title: ".cyan) @@ -90,8 +87,7 @@ class Main : AppCommand(name = "kotatsu-dl") { } var chapters = manga.chapters if (chapters.isNullOrEmpty()) { - System.err.println("Manga contains no chapters") - throw ProgramResult(1) + error("Manga contains no chapters") } chapters = askSelectBranch(chapters) colored { diff --git a/src/main/kotlin/org/koitharu/kotatsu/dl/util/AppCommand.kt b/src/main/kotlin/org/koitharu/kotatsu/dl/util/AppCommand.kt index b2fd35b..77bd63a 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/dl/util/AppCommand.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/dl/util/AppCommand.kt @@ -39,7 +39,7 @@ abstract class AppCommand(name: String) : CoreSuspendingCliktCommand(name) { val exitCode = try { invoke() } catch (e: IllegalStateException) { - throw PrintMessage(e.message.ifNullOrEmpty { GENERIC_ERROR_MSG }, 2, true) + throw PrintMessage(e.message.ifNullOrEmpty { GENERIC_ERROR_MSG }, 1, true) } catch (e: NotImplementedError) { throw PrintMessage(e.message.ifNullOrEmpty { GENERIC_ERROR_MSG }, 2, true) }