diff options
author | nea <romangraef@loves.dicksinhisan.us> | 2021-12-09 02:56:50 +0100 |
---|---|---|
committer | nea <romangraef@loves.dicksinhisan.us> | 2021-12-09 02:56:50 +0100 |
commit | f8c6246a262b1d15e42ce812363f7d4e4eb16b8a (patch) | |
tree | 373746da7e8b20a51e65d0a3761ddfc6691df043 /src/main/kotlin/moe/nea89/website/Command.kt | |
parent | 06e71e5aa081a561498f00f963a393367b917a78 (diff) | |
download | neamoe-f8c6246a262b1d15e42ce812363f7d4e4eb16b8a.tar.gz neamoe-f8c6246a262b1d15e42ce812363f7d4e4eb16b8a.tar.bz2 neamoe-f8c6246a262b1d15e42ce812363f7d4e4eb16b8a.zip |
suspend shell executor
Diffstat (limited to 'src/main/kotlin/moe/nea89/website/Command.kt')
-rw-r--r-- | src/main/kotlin/moe/nea89/website/Command.kt | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/main/kotlin/moe/nea89/website/Command.kt b/src/main/kotlin/moe/nea89/website/Command.kt index cb59d0a..b8e4675 100644 --- a/src/main/kotlin/moe/nea89/website/Command.kt +++ b/src/main/kotlin/moe/nea89/website/Command.kt @@ -1,16 +1,11 @@ package moe.nea89.website -interface Command { - val name: String - val aliases: Set<String> - fun run(console: KConsole, name: String, args: List<String>) -} +data class Command( + val name: String, + val aliases: Set<String>, + val runner: suspend ShellExecutionContext.() -> Unit, +) -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)) -}
\ No newline at end of file +fun command(name: String, vararg aliases: String, block: suspend ShellExecutionContext. () -> Unit) = + Command(name, aliases.toSet(), block)
\ No newline at end of file |