Files
labProg5/app/src/main/kotlin/command/CommandManager.kt

26 lines
504 B
Kotlin

package command
import command.commands.*
import io.IOHandler
class CommandManager {
private val commands = mutableMapOf<String, Command>()
fun register(command: Command) {
commands[command.name] = command
}
fun initCommand(
input: String,
io: IOHandler,
) {
val command = commands[input]
if (command != null) {
command?.execute()
} else {
io.println("команда не найдена")
}
}
}