diff --git a/src/commonMain/kotlin/teksturepako/pakku/api/projects/UpdateStrategy.kt b/src/commonMain/kotlin/teksturepako/pakku/api/projects/UpdateStrategy.kt index 05c15fc3..3ce8da0d 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/api/projects/UpdateStrategy.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/api/projects/UpdateStrategy.kt @@ -1,8 +1,8 @@ package teksturepako.pakku.api.projects -enum class UpdateStrategy(name: String, val short: String) +enum class UpdateStrategy(serialName: String) { - LATEST("latest", "^"), - SAME_LATEST("same_latest", "★^"), // TODO: To be implemented - NONE("none", "✖^") + LATEST("latest"), + SAME_LATEST("same_latest"), // TODO: To be implemented + NONE("none") } \ No newline at end of file diff --git a/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Ls.kt b/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Ls.kt index 65242155..b0284fc4 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Ls.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Ls.kt @@ -56,9 +56,10 @@ class Ls : CliktCommand("List projects") cell(project.getFlavoredSlug()) val name = if (newProjects != null) runBlocking { - project.getFlavoredUpdateMsg(newProjects.await()) + project.getFlavoredName(nameMaxLengthOpt) + project.getFlavoredUpdateMsg(terminal.theme, newProjects.await()) + + project.getFlavoredName(terminal.theme, nameMaxLengthOpt) } - else " " + project.getFlavoredName(nameMaxLengthOpt) + else " " + project.getFlavoredName(terminal.theme, nameMaxLengthOpt) cell(name) diff --git a/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Status.kt b/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Status.kt index db6502c2..e37b25b2 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Status.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Status.kt @@ -52,7 +52,7 @@ class Status: CliktCommand("Get status of your modpack") { terminal.println(grid { currentProjects.filter { updatedProjects containsProject it }.map { project -> - row(project.getFlavoredSlug(), project.getFlavoredName()) + row(project.getFlavoredSlug(), project.getFlavoredName(terminal.theme)) val updatedProject = updatedProjects.find { it isAlmostTheSameAs project } updatedProject?.run { diff --git a/src/commonMain/kotlin/teksturepako/pakku/cli/ui/CliThemes.kt b/src/commonMain/kotlin/teksturepako/pakku/cli/ui/CliThemes.kt index 70cfd161..36874505 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/cli/ui/CliThemes.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/cli/ui/CliThemes.kt @@ -6,10 +6,19 @@ object CliThemes { val Default: Theme = Theme(Theme.Default) { strings["pakku.prefix"] = "❯❯❯" + strings["pakku.warning_sign"] = "⚠" + + strings["pakku.update_strategy.latest"] = "^" + strings["pakku.update_strategy.same_latest"] = "★^" + strings["pakku.update_strategy.none"] = "✖^" } val Ascii: Theme = Theme(this.Default) { strings["pakku.prefix"] = ">>>" + strings["pakku.warning_sign"] = "!" + + strings["pakku.update_strategy.same_latest"] = "*^" + strings["pakku.update_strategy.none"] = "x^" strings["list.number.separator"] = "." strings["list.bullet.text"] = "*" diff --git a/src/commonMain/kotlin/teksturepako/pakku/cli/ui/ProjectMsg.kt b/src/commonMain/kotlin/teksturepako/pakku/cli/ui/ProjectMsg.kt index 2759c2e2..1d3897e7 100644 --- a/src/commonMain/kotlin/teksturepako/pakku/cli/ui/ProjectMsg.kt +++ b/src/commonMain/kotlin/teksturepako/pakku/cli/ui/ProjectMsg.kt @@ -2,6 +2,7 @@ package teksturepako.pakku.cli.ui import com.github.ajalt.mordant.rendering.TextColors.* import com.github.ajalt.mordant.rendering.TextStyle +import com.github.ajalt.mordant.rendering.Theme import teksturepako.pakku.api.data.allEqual import teksturepako.pakku.api.platforms.Multiplatform import teksturepako.pakku.api.platforms.Platform @@ -9,7 +10,7 @@ import teksturepako.pakku.api.projects.Project import teksturepako.pakku.api.projects.UpdateStrategy import teksturepako.pakku.api.projects.containsProject -fun Project.getFlavoredName(maxLength: Int? = null): String? +fun Project.getFlavoredName(theme: Theme, maxLength: Int? = null): String? { val name = this.name.values.firstOrNull()?.let { if (maxLength != null && it.length > maxLength) @@ -26,29 +27,25 @@ fun Project.getFlavoredName(maxLength: Int? = null): String? { if (this.hasNoFiles()) { - TextStyle(bgColor = white, color = red)("⚠$name") + TextStyle(bgColor = white, color = red)("${theme.string("pakku.warning_sign", "!")}$name") } else { - TextStyle(bgColor = white, color = black)("⚠$name") + TextStyle(bgColor = white, color = black)("${theme.string("pakku.warning_sign", "!")}$name") } } } } -fun Project.getFlavoredUpdateMsg(updatedProjects: MutableSet): String = when (this.updateStrategy) +fun Project.getFlavoredUpdateMsg(theme: Theme, updatedProjects: MutableSet): String = when (this.updateStrategy) { - UpdateStrategy.LATEST -> + UpdateStrategy.LATEST -> { - if (updatedProjects containsProject this) - { - blue(this.updateStrategy.short) - } - else brightGreen(this.updateStrategy.short) + val symbol = theme.string("pakku.update_strategy.latest", "^") + if (updatedProjects containsProject this) blue(symbol) else brightGreen(symbol) } - - UpdateStrategy.NONE -> red(this.updateStrategy.short) - else -> cyan(this.updateStrategy.short) + UpdateStrategy.SAME_LATEST -> cyan(theme.string("pakku.update_strategy.same_latest", "*^")) + UpdateStrategy.NONE -> red(theme.string("pakku.update_strategy.none", "x^")) } fun Project.getFlavoredSlug(): String