-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathort-analyzer-parser.main.kts
More file actions
executable file
·42 lines (32 loc) · 1.48 KB
/
ort-analyzer-parser.main.kts
File metadata and controls
executable file
·42 lines (32 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env kotlin
@file:CompilerOptions("-jvm-target", "21")
@file:DependsOn("com.github.ajalt.clikt:clikt-jvm:5.1.0")
@file:DependsOn("org.ossreviewtoolkit:analyzer:82.2.0")
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.output.MordantHelpFormatter
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.types.file
import org.ossreviewtoolkit.model.OrtResult
import org.ossreviewtoolkit.model.VcsType
import org.ossreviewtoolkit.model.readValue
object : CliktCommand(name = __FILE__.name) {
val ortResultFile by argument()
.file(mustExist = true, canBeFile = true, canBeDir = false, mustBeWritable = false, mustBeReadable = true, canBeSymlink = true)
init {
context {
helpFormatter = { MordantHelpFormatter(context = it, "*", showDefaultValues = true) }
}
}
override fun help(context: Context) = "An example to show how to parse analyzer results."
override fun run() {
val ortResult = ortResultFile.readValue<OrtResult>()
val svnPackages = ortResult.analyzer?.result?.packages?.filter { it.vcsProcessed.type == VcsType.SUBVERSION }.orEmpty()
echo("Number of Subversion packages: ${svnPackages.size}")
svnPackages.map { it.id.toCoordinates() }.sorted().forEach {
echo(it)
}
}
}.main(args)