chore(command): rename command interface
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package command
|
||||
|
||||
interface CommandHandler {
|
||||
interface Command {
|
||||
val name: String
|
||||
val description: String
|
||||
|
||||
fun execute(args: String? = null)
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import command.commands.*
|
||||
import io.IOHandler
|
||||
|
||||
class CommandManager {
|
||||
private val commands = mutableMapOf<String, CommandHandler>()
|
||||
private val commands = mutableMapOf<String, Command>()
|
||||
|
||||
fun register(command: CommandHandler) {
|
||||
fun register(command: Command) {
|
||||
commands[command.name] = command
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import kotlin.text.toLong
|
||||
import kotlin.text.toLongOrNull
|
||||
|
||||
class InputHandler {
|
||||
fun productInput(): Product {
|
||||
fun read(): Product {
|
||||
println("введите имя")
|
||||
val name = readLine() ?: "default"
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package command.commands
|
||||
|
||||
import command.CommandHandler
|
||||
import command.Command
|
||||
import command.ProductReader
|
||||
import io.IOHandler
|
||||
|
||||
class Add(
|
||||
private val io: IOHandler,
|
||||
) : CommandHandler {
|
||||
) : Command {
|
||||
override val name = "add"
|
||||
override val description = "add product"
|
||||
|
||||
override fun execute(args: String?) {
|
||||
io.println("fdada")
|
||||
io.println("добавляем продукт")
|
||||
ProductReader().read()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package command.commands
|
||||
|
||||
import command.CommandHandler
|
||||
import command.Command
|
||||
import io.IOHandler
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class Exit(
|
||||
private val io: IOHandler,
|
||||
) : CommandHandler {
|
||||
) : Command {
|
||||
override val name = "exit"
|
||||
override val description = "exit"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user