chore(command): rename command interface

This commit is contained in:
2026-03-01 03:05:49 +03:00
parent cb64d2dd9d
commit 406378c7ad
5 changed files with 12 additions and 9 deletions

View File

@@ -1,7 +1,8 @@
package command package command
interface CommandHandler { interface Command {
val name: String val name: String
val description: String val description: String
fun execute(args: String? = null) fun execute(args: String? = null)
} }

View File

@@ -4,9 +4,9 @@ import command.commands.*
import io.IOHandler import io.IOHandler
class CommandManager { 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 commands[command.name] = command
} }

View File

@@ -10,7 +10,7 @@ import kotlin.text.toLong
import kotlin.text.toLongOrNull import kotlin.text.toLongOrNull
class InputHandler { class InputHandler {
fun productInput(): Product { fun read(): Product {
println("введите имя") println("введите имя")
val name = readLine() ?: "default" val name = readLine() ?: "default"

View File

@@ -1,15 +1,17 @@
package command.commands package command.commands
import command.CommandHandler import command.Command
import command.ProductReader
import io.IOHandler import io.IOHandler
class Add( class Add(
private val io: IOHandler, private val io: IOHandler,
) : CommandHandler { ) : Command {
override val name = "add" override val name = "add"
override val description = "add product" override val description = "add product"
override fun execute(args: String?) { override fun execute(args: String?) {
io.println("fdada") io.println("добавляем продукт")
ProductReader().read()
} }
} }

View File

@@ -1,12 +1,12 @@
package command.commands package command.commands
import command.CommandHandler import command.Command
import io.IOHandler import io.IOHandler
import kotlin.system.exitProcess import kotlin.system.exitProcess
class Exit( class Exit(
private val io: IOHandler, private val io: IOHandler,
) : CommandHandler { ) : Command {
override val name = "exit" override val name = "exit"
override val description = "exit" override val description = "exit"