Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit 78683ca

Browse files
authored
Add messageTemplate and level params to baseline merger (#77)
* Add messageTemplate and level params to baseline merger This adds two new options, see their `help` values in code for details. * Detekt * Api dump
1 parent ddca1b5 commit 78683ca

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

api/kotlin-cli-util.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ public final class slack/cli/lint/LintBaselineMergerCli : com/github/ajalt/clikt
8080
public fun run ()V
8181
}
8282

83+
public synthetic class slack/cli/lint/LintBaselineMergerCli$EntriesMappings {
84+
public static final synthetic field entries$0 Lkotlin/enums/EnumEntries;
85+
}
86+
8387
public final class slack/cli/lint/LintBaselineMergerCli$Factory : slack/cli/CommandFactory {
8488
public fun <init> ()V
8589
public fun create ()Lcom/github/ajalt/clikt/core/CliktCommand;

src/main/kotlin/slack/cli/lint/LintBaselineMergerCli.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
package slack.cli.lint
1717

1818
import com.github.ajalt.clikt.core.CliktCommand
19+
import com.github.ajalt.clikt.parameters.options.default
1920
import com.github.ajalt.clikt.parameters.options.flag
2021
import com.github.ajalt.clikt.parameters.options.option
2122
import com.github.ajalt.clikt.parameters.options.required
23+
import com.github.ajalt.clikt.parameters.types.enum
2224
import com.github.ajalt.clikt.parameters.types.path
2325
import com.google.auto.service.AutoService
2426
import com.tickaroo.tikxml.converter.htmlescape.StringEscapeUtils
@@ -82,6 +84,28 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) {
8284

8385
private val outputFile by option("--output-file", "-o").path(canBeDir = false).required()
8486

87+
private val messageTemplate by
88+
option(
89+
"--message-template",
90+
"-m",
91+
help =
92+
"Template for messages with each issue. This message can optionally " +
93+
"contain '{id}' in it to be replaced with the issue ID."
94+
)
95+
.default("Lint issue {id}")
96+
97+
private val level by
98+
option(
99+
"--level",
100+
"-l",
101+
help =
102+
"Priority level. Defaults to Error. Options are ${
103+
Level.entries.joinToString(separator = ", ", prefix = "[", postfix = "]", transform = Level::name)
104+
}"
105+
)
106+
.enum<Level>()
107+
.default(Level.Error)
108+
85109
private val verbose by option("--verbose", "-v").flag()
86110

87111
@OptIn(ExperimentalSerializationApi::class)
@@ -136,11 +160,11 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) {
136160
add(
137161
Result(
138162
ruleID = id,
139-
level = Level.Error,
163+
level = level,
140164
ruleIndex = ruleIndices.getValue(id),
141165
locations =
142166
locations.sortedBy { it.physicalLocation?.artifactLocation?.uri },
143-
message = Message(text = "Lint issue $id")
167+
message = Message(text = messageTemplate.replace("{id}", id))
144168
)
145169
)
146170
}

0 commit comments

Comments
 (0)