From a2cd4ef7558436572ecb13b7bacd8e9f79b41ec3 Mon Sep 17 00:00:00 2001 From: DinoMarlir <72864666+DinoMarlir@users.noreply.github.com> Date: Tue, 21 May 2024 13:20:52 +0200 Subject: [PATCH] added mordant + renamed `Terminal.kt` to `CLI.kt` --- common/build.gradle.kts | 2 ++ .../bluecloud/common/console/cli/{Terminal.kt => CLI.kt} | 4 ++-- common/src/test/kotlin/ConsoleTest.kt | 7 +++---- gradle/libs.versions.toml | 3 +++ runner/src/test/kotlin/Test.kt | 4 ---- .../blueamethyst/bluecloud/wrapper/logic/WrapperWatcher.kt | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) rename common/src/main/kotlin/me/blueamethyst/bluecloud/common/console/cli/{Terminal.kt => CLI.kt} (95%) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index bac35cf..eac0f31 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -14,6 +14,8 @@ dependencies { implementation(libs.bundles.ktorClient) implementation(libs.guice) implementation(libs.clikt) + implementation(libs.mordant) + implementation(libs.mordantCoroutines) implementation(kotlin("reflect")) } diff --git a/common/src/main/kotlin/me/blueamethyst/bluecloud/common/console/cli/Terminal.kt b/common/src/main/kotlin/me/blueamethyst/bluecloud/common/console/cli/CLI.kt similarity index 95% rename from common/src/main/kotlin/me/blueamethyst/bluecloud/common/console/cli/Terminal.kt rename to common/src/main/kotlin/me/blueamethyst/bluecloud/common/console/cli/CLI.kt index 96077f8..b968912 100644 --- a/common/src/main/kotlin/me/blueamethyst/bluecloud/common/console/cli/Terminal.kt +++ b/common/src/main/kotlin/me/blueamethyst/bluecloud/common/console/cli/CLI.kt @@ -6,11 +6,11 @@ import me.blueamethyst.bluecloud.common.console.Logger import me.blueamethyst.bluecloud.common.console.cli.command.RootCommand import java.io.Closeable -class Terminal( +class CLI( private val logger: Logger, private val prompt: String, val subCommands: List -): Thread(), Closeable { +): Thread("cli-thread"), Closeable { var running = false; private set diff --git a/common/src/test/kotlin/ConsoleTest.kt b/common/src/test/kotlin/ConsoleTest.kt index 5708ed1..fee3eab 100644 --- a/common/src/test/kotlin/ConsoleTest.kt +++ b/common/src/test/kotlin/ConsoleTest.kt @@ -1,11 +1,10 @@ import com.github.ajalt.clikt.core.CliktCommand import me.blueamethyst.bluecloud.common.console.ConsoleColors import me.blueamethyst.bluecloud.common.console.Logger -import me.blueamethyst.bluecloud.common.console.cli.Terminal -import java.net.InetAddress +import me.blueamethyst.bluecloud.common.console.cli.CLI fun main() { - val terminal = Terminal( + val cli = CLI( Logger("Terminal", true), "${ConsoleColors.YELLOW_BRIGHT}CLI${ConsoleColors.BLACK_BRIGHT}@${ConsoleColors.BLUE_BRIGHT}BlueCloud ${ConsoleColors.BLACK_BRIGHT}ยป ${ConsoleColors.RESET}", listOf( @@ -13,7 +12,7 @@ fun main() { ) ) - terminal.start() + cli.start() while (true) { Thread.sleep(1000) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5d663dd..55bc583 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,6 +4,7 @@ guice = "7.0.0" ktor = "2.3.11" kotlinx-serialization = "1.6.3" clikt = "4.4.0" +mordant = "2.6.0" [libraries] kotlinxCoroutinesCore = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesCore" } @@ -15,6 +16,8 @@ ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = " ktor-client-content-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" } ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" } clikt = { group = "com.github.ajalt.clikt", name = "clikt", version.ref = "clikt" } +mordant = { group = "com.github.ajalt.mordant", name = "mordant", version.ref = "mordant" } +mordantCoroutines = { group = "com.github.ajalt.mordant", name = "mordant-coroutines", version.ref = "mordant" } [bundles] ktorClient = ["ktor-client-core", "ktor-client-cio", "ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"] \ No newline at end of file diff --git a/runner/src/test/kotlin/Test.kt b/runner/src/test/kotlin/Test.kt index 20087c8..cd0819c 100644 --- a/runner/src/test/kotlin/Test.kt +++ b/runner/src/test/kotlin/Test.kt @@ -1,7 +1,3 @@ -import me.blueamethyst.bluecloud.api.service.ICloudService -import me.blueamethyst.bluecloud.runner.ProcessRegistry -import java.util.* - /* fun main() { val call = ProcessRegistry().getServiceProcess("jvm")!!.constructors.firstOrNull()!!.call() diff --git a/wrapper/src/main/kotlin/me/blueamethyst/bluecloud/wrapper/logic/WrapperWatcher.kt b/wrapper/src/main/kotlin/me/blueamethyst/bluecloud/wrapper/logic/WrapperWatcher.kt index edf6571..a067fbb 100644 --- a/wrapper/src/main/kotlin/me/blueamethyst/bluecloud/wrapper/logic/WrapperWatcher.kt +++ b/wrapper/src/main/kotlin/me/blueamethyst/bluecloud/wrapper/logic/WrapperWatcher.kt @@ -1,10 +1,10 @@ package me.blueamethyst.bluecloud.wrapper.logic import me.blueamethyst.bluecloud.api.annontations.InternalBlueCloudApi -import me.blueamethyst.bluecloud.wrapper.logic.WrapperQueue as Queue -import me.blueamethyst.bluecloud.wrapper.logic.WrapperServiceProcessor as ServiceProcessor import me.blueamethyst.bluecloud.wrapper.Wrapper.Companion.logger import java.io.Closeable +import me.blueamethyst.bluecloud.wrapper.logic.WrapperQueue as Queue +import me.blueamethyst.bluecloud.wrapper.logic.WrapperServiceProcessor as ServiceProcessor @InternalBlueCloudApi class WrapperWatcher: Thread("wrapper-watcher"), Closeable {