Skip to content

Commit

Permalink
feat(helper-cli): Add an option to override the repository configuration
Browse files Browse the repository at this point in the history
`orthw` (bash) organizes the OrtResult files and repository
configuration separately. So, before running any command on the
`OrtResult` the repository configuration needs to be overridden. Extend
the `ListPackagesCommand` by a dedicated option, analog to other commands
such as `ListLicensesCommand`.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Sep 27, 2024
1 parent 1f4d723 commit e18b08e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion helper-cli/src/main/kotlin/commands/ListPackagesCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.github.ajalt.clikt.parameters.types.file

import org.ossreviewtoolkit.helper.utils.OrtHelperCommand
import org.ossreviewtoolkit.helper.utils.readOrtResult
import org.ossreviewtoolkit.helper.utils.replaceConfig
import org.ossreviewtoolkit.model.Identifier
import org.ossreviewtoolkit.model.PackageType
import org.ossreviewtoolkit.model.PackageType.PACKAGE
Expand Down Expand Up @@ -82,8 +83,15 @@ internal class ListPackagesCommand : OrtHelperCommand(
help = "Only list packages distinct by type, namespace and name."
).flag()

private val repositoryConfigurationFile by option(
"--repository-configuration-file",
help = "Override the repository configuration contained in the ORT result."
).convert { it.expandTilde() }
.file(mustExist = true, canBeFile = true, canBeDir = false, mustBeWritable = false, mustBeReadable = true)
.convert { it.absoluteFile.normalize() }

override fun run() {
val ortResult = readOrtResult(ortFile)
val ortResult = readOrtResult(ortFile).replaceConfig(repositoryConfigurationFile)

val licenseInfoResolver = ortResult.createLicenseInfoResolver()

Expand Down

0 comments on commit e18b08e

Please sign in to comment.