chore(command): rename command interface
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user