-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from JetBrains/baseline-include-absent
Support baseline-include-absent flag in baseline cli
- Loading branch information
Showing
6 changed files
with
79 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import BaselineCli.process | ||
import com.github.ajalt.clikt.core.CliktCommand | ||
import com.github.ajalt.clikt.parameters.options.flag | ||
import com.github.ajalt.clikt.parameters.options.option | ||
import com.github.ajalt.clikt.parameters.options.required | ||
import com.github.ajalt.clikt.parameters.types.int | ||
import kotlin.system.exitProcess | ||
|
||
const val THRESHOLD_EXIT = 255 | ||
const val ERROR_EXIT = 1 | ||
|
||
fun main(args: Array<String>) { | ||
val map = mutableMapOf<String, String>() | ||
|
||
var i = 0 | ||
while (i < args.size) { | ||
when (args[i]) { | ||
"-r" -> map["sarifReport"] = args.getOrNull(i + 1) ?: printUsageAndExit() | ||
"-b" -> map["baselineReport"] = args.getOrNull(i + 1) ?: printUsageAndExit() | ||
"-f" -> map["failThreshold"] = args.getOrNull(i + 1) ?: printUsageAndExit() | ||
} | ||
i += 2 | ||
} | ||
|
||
if (!map.contains("sarifReport")) { | ||
printUsageAndExit() | ||
class BaselineCommand : CliktCommand() { | ||
private val sarifReport: String by option("-r", help = "Sarif report path").required() | ||
private val baselineReport: String? by option("-b", help = "Baseline report path") | ||
private val baselineIncludeAbsent: Boolean by option("-i", help = "Baseline include absent status").flag() | ||
private val failThreshold: Int? by option("-f", help = "Fail threshold").int() | ||
override fun run() { | ||
val ret = process( | ||
BaselineOptions(sarifReport, baselineReport, failThreshold, baselineIncludeAbsent), | ||
{ println(it) }, | ||
{ System.err.println(it) }) | ||
exitProcess(ret) | ||
} | ||
|
||
val ret = process(map, { println(it) }, { System.err.println(it) }) | ||
exitProcess(ret) | ||
} | ||
|
||
fun printUsageAndExit(): Nothing { | ||
println("Usage: -r <sarif_report> [-b <baseline_report>] [-f <fail_threshold>]") | ||
exitProcess(1) | ||
} | ||
data class BaselineOptions(val sarifPath: String, | ||
val baselinePath: String? = null, | ||
val failThreshold: Int? = null, | ||
val includeAbsent: Boolean = false) | ||
|
||
fun main(args: Array<String>) = BaselineCommand().main(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ exclude: | |
- name: All | ||
paths: | ||
- sarif/src/test/resources/ | ||
dependencyIgnores: | ||
- name: "colormath-jvm" |