summaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea89/website/Command.kt
blob: cb59d0ad38de613a207e72b723ef556e6785192d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package moe.nea89.website

interface Command {
    val name: String
    val aliases: Set<String>
    fun run(console: KConsole, name: String, args: List<String>)
}

data class CommandContext(val console: KConsole, val name: String, val args: List<String>)

fun command(name: String, vararg aliases: String, block: CommandContext. () -> Unit) = object : Command {
    override val name: String = name
    override val aliases: Set<String> = aliases.toSet()

    override fun run(console: KConsole, name: String, args: List<String>) = block(CommandContext(console, name, args))
}