|
16 | 16 | package slack.cli.lint |
17 | 17 |
|
18 | 18 | import com.github.ajalt.clikt.core.CliktCommand |
| 19 | +import com.github.ajalt.clikt.parameters.options.default |
19 | 20 | import com.github.ajalt.clikt.parameters.options.flag |
20 | 21 | import com.github.ajalt.clikt.parameters.options.option |
21 | 22 | import com.github.ajalt.clikt.parameters.options.required |
| 23 | +import com.github.ajalt.clikt.parameters.types.enum |
22 | 24 | import com.github.ajalt.clikt.parameters.types.path |
23 | 25 | import com.google.auto.service.AutoService |
24 | 26 | import com.tickaroo.tikxml.converter.htmlescape.StringEscapeUtils |
@@ -82,6 +84,28 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { |
82 | 84 |
|
83 | 85 | private val outputFile by option("--output-file", "-o").path(canBeDir = false).required() |
84 | 86 |
|
| 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 | + |
85 | 109 | private val verbose by option("--verbose", "-v").flag() |
86 | 110 |
|
87 | 111 | @OptIn(ExperimentalSerializationApi::class) |
@@ -136,11 +160,11 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { |
136 | 160 | add( |
137 | 161 | Result( |
138 | 162 | ruleID = id, |
139 | | - level = Level.Error, |
| 163 | + level = level, |
140 | 164 | ruleIndex = ruleIndices.getValue(id), |
141 | 165 | locations = |
142 | 166 | locations.sortedBy { it.physicalLocation?.artifactLocation?.uri }, |
143 | | - message = Message(text = "Lint issue $id") |
| 167 | + message = Message(text = messageTemplate.replace("{id}", id)) |
144 | 168 | ) |
145 | 169 | ) |
146 | 170 | } |
|
0 commit comments