Skip to content

Commit

Permalink
feat(helper-cli): Allow to omit the version when listing packages
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jul 11, 2024
1 parent e4aa9e9 commit b37ac5e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion helper-cli/src/main/kotlin/commands/ListPackagesCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 {
Expand Down

0 comments on commit b37ac5e

Please sign in to comment.