fix: Do not print patch description if null

This commit is contained in:
oSumAtrIX
2025-04-25 22:26:45 +02:00
parent 1717cc66f7
commit bba90fede8

View File

@@ -85,58 +85,55 @@ internal object ListPatchesCommand : Runnable {
} }
} }
fun PatchOption<*>.buildString() = fun PatchOption<*>.buildString() = buildString {
appendLine("Title: $title")
description?.let { appendLine("Description: $it") }
appendLine("Required: $required")
default?.let {
appendLine("Key: $key")
append("Default: $it")
} ?: append("Key: $key")
values?.let { values ->
appendLine("\nPossible values:")
append(values.map { "${it.value} (${it.key})" }.joinToString("\n").prependIndent("\t"))
}
append("\nType: $type")
}
fun IndexedValue<Patch<*>>.buildString() = let { (index, patch) ->
buildString { buildString {
appendLine("Title: $title") if (withIndex) appendLine("Index: $index")
description?.let { appendLine("Description: $it") }
appendLine("Required: $required")
default?.let {
appendLine("Key: $key")
append("Default: $it")
} ?: append("Key: $key")
values?.let { values -> append("Name: ${patch.name}")
appendLine("\nPossible values:")
append(values.map { "${it.value} (${it.key})" }.joinToString("\n").prependIndent("\t")) if (withDescriptions) patch.description?.let { append("\nDescription: $it") }
append("\nEnabled: ${patch.use}")
if (withOptions && patch.options.isNotEmpty()) {
appendLine("\nOptions:")
append(
patch.options.values.joinToString("\n\n") { option ->
option.buildString()
}.prependIndent("\t"),
)
} }
append("\nType: $type") if (withPackages && patch.compatiblePackages != null) {
} appendLine("\nCompatible packages:")
append(
fun IndexedValue<Patch<*>>.buildString() = patch.compatiblePackages!!.joinToString("\n") {
let { (index, patch) -> it.buildString()
buildString { }.prependIndent("\t"),
if (withIndex) appendLine("Index: $index") )
append("Name: ${patch.name}")
if (withDescriptions) append("\nDescription: ${patch.description}")
append("\nEnabled: ${patch.use}")
if (withOptions && patch.options.isNotEmpty()) {
appendLine("\nOptions:")
append(
patch.options.values.joinToString("\n\n") { option ->
option.buildString()
}.prependIndent("\t"),
)
}
if (withPackages && patch.compatiblePackages != null) {
appendLine("\nCompatible packages:")
append(
patch.compatiblePackages!!.joinToString("\n") {
it.buildString()
}.prependIndent("\t"),
)
}
} }
} }
}
fun Patch<*>.filterCompatiblePackages(name: String) = fun Patch<*>.filterCompatiblePackages(name: String) = compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name } ?: withUniversalPatches
?: withUniversalPatches
val patches = loadPatchesFromJar(patchesFiles).withIndex().toList() val patches = loadPatchesFromJar(patchesFiles).withIndex().toList()