summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-08 11:01:25 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-08 11:01:25 +0100
commitec580656085dfeebcae1aff58c372f8b56f97df2 (patch)
treec955515ff4f6918d842a14978cd291ab5d80fa13
parentc5e1716d27602f5daaf86d9dbf1f39bc1124d025 (diff)
downloadSkyHanniChangelogBuilder-ec580656085dfeebcae1aff58c372f8b56f97df2.tar.gz
SkyHanniChangelogBuilder-ec580656085dfeebcae1aff58c372f8b56f97df2.tar.bz2
SkyHanniChangelogBuilder-ec580656085dfeebcae1aff58c372f8b56f97df2.zip
show amount of characters used in message for discord output types
-rw-r--r--src/main/kotlin/Main.kt30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index fb27357..5a5b564 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -124,18 +124,36 @@ private fun print(
OutputType.GITHUB -> " * "
OutputType.DISCORD_INTERNAL -> " - "
}
+ val list = createPrint(categories, outputType, allChanges, extraInfoPrefix)
val border = "================================================================================="
println("")
println("outputType ${outputType.name.lowercase()}:")
+ val totalLength = list.sumOf { it.length }
+ if (outputType != OutputType.GITHUB) {
+ println("$totalLength/2000 characters used")
+ }
println(border)
println("## $title")
+ for (line in list) {
+ println(line)
+ }
+ println(border)
+}
+
+private fun createPrint(
+ categories: MutableList<Category>,
+ outputType: OutputType,
+ allChanges: MutableList<Change>,
+ extraInfoPrefix: String,
+): MutableList<String> {
+ val list = mutableListOf<String>()
for (category in allowedCategories.map { getCategory(categories, it) }) {
if (outputType == OutputType.DISCORD_PUBLIC && category.name == "Technical Details") continue
val changes = allChanges.filter { it.category == category }
if (changes.isEmpty()) continue
- println("### " + category.name)
+ list.add("### " + category.name)
if (outputType == OutputType.DISCORD_PUBLIC) {
- println("```diff")
+ list.add("```diff")
}
for (change in changes) {
val pr = when (outputType) {
@@ -144,16 +162,16 @@ private fun print(
OutputType.DISCORD_INTERNAL -> " [PR](<${change.prLink}>)"
}
val changePrefix = getChangePrefix(category.name, outputType)
- println("$changePrefix${change.text} - ${change.author}$pr")
+ list.add("$changePrefix${change.text} - ${change.author}$pr")
for (s in change.extraInfo) {
- println("$extraInfoPrefix$s")
+ list.add("$extraInfoPrefix$s")
}
}
if (outputType == OutputType.DISCORD_PUBLIC) {
- println("```")
+ list.add("```")
}
}
- println(border)
+ return list
}
fun getChangePrefix(name: String, outputType: OutputType): String = when (outputType) {