forked from SteamWar/SteamWar
24 lines
769 B
Kotlin
24 lines
769 B
Kotlin
package de.steamwar.commands.database
|
|
|
|
import com.github.ajalt.clikt.core.CliktCommand
|
|
import com.github.ajalt.clikt.core.CliktError
|
|
import com.github.ajalt.clikt.core.Context
|
|
import com.github.ajalt.clikt.core.findOrSetObject
|
|
import com.github.ajalt.clikt.parameters.options.flag
|
|
import com.github.ajalt.clikt.parameters.options.option
|
|
import de.steamwar.db.Database
|
|
|
|
class DatabaseCommand : CliktCommand(name = "db") {
|
|
val useProduction by option().flag()
|
|
val db by findOrSetObject { Database }
|
|
|
|
override fun help(context: Context): String =
|
|
"Run database commands"
|
|
|
|
override fun run() {
|
|
if (!useProduction && db.database == "production") {
|
|
throw CliktError("You should not use the production database!")
|
|
}
|
|
}
|
|
}
|