You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
800 B
Kotlin
27 lines
800 B
Kotlin
package moe.odango.index.cli
|
|
|
|
import com.github.ajalt.clikt.core.CliktCommand
|
|
import com.github.ajalt.clikt.parameters.options.option
|
|
import kotlinx.coroutines.runBlocking
|
|
import moe.odango.index.sync.AniDBTitleSync
|
|
import java.io.File
|
|
|
|
class AniDBSync : CliktCommand(name = "anidb",help = "Sync the titles from AniDB with the local database") {
|
|
private val file by option(help = "Read from file instead of downloading")
|
|
|
|
override fun run() {
|
|
val sync = AniDBTitleSync()
|
|
val file = file
|
|
|
|
runBlocking {
|
|
if (file == null) {
|
|
sync.run()
|
|
} else {
|
|
val fileObj = File(file).takeIf { it.isFile } ?: throw RuntimeException("File doesn't exist")
|
|
sync.syncWithFile(fileObj)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|