forked from SteamWar/SteamWar
- add Clikt-based `sw` entrypoint and subcommands - include database, user, dev, and profiler commands - wire CLI build and CI install/release steps
23 lines
760 B
Kotlin
23 lines
760 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!")
|
|
}
|
|
}
|
|
}
|