diff --git a/helper-cli/src/main/kotlin/commands/ListPackagesCommand.kt b/helper-cli/src/main/kotlin/commands/ListPackagesCommand.kt index c4e4dbf6f1fab..8477425cb4d21 100644 --- a/helper-cli/src/main/kotlin/commands/ListPackagesCommand.kt +++ b/helper-cli/src/main/kotlin/commands/ListPackagesCommand.kt @@ -77,6 +77,11 @@ internal class ListPackagesCommand : CliktCommand( help = "Only list non-excluded packages." ).flag() + private val omitVersion by option( + "--omit-version", + help = "Only list packages distinct by type, namespace and name." + ).flag() + override fun run() { val ortResult = readOrtResult(ortFile) @@ -97,7 +102,9 @@ internal class ListPackagesCommand : CliktCommand( matchDetectedLicenses.isEmpty() || (matchDetectedLicenses - getDetectedLicenses(id)).isEmpty() }.filter { id -> !offendingOnly || id in packagesWithOffendingRuleViolations - }.sortedBy { it } + }.map { + it.takeUnless { omitVersion } ?: it.copy(version = "") + }.distinct().sortedBy { it } val result = buildString { packages.forEach {