File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
plugins/commands/config/src/main/kotlin Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ import com.github.ajalt.clikt.parameters.types.file
3131import com.github.ajalt.mordant.rendering.Theme
3232
3333import org.ossreviewtoolkit.model.config.OrtConfiguration
34+ import org.ossreviewtoolkit.model.config.RepositoryConfiguration
35+ import org.ossreviewtoolkit.model.readValue
3436import org.ossreviewtoolkit.plugins.api.OrtPlugin
3537import org.ossreviewtoolkit.plugins.api.PluginDescriptor
3638import org.ossreviewtoolkit.plugins.commands.api.OrtCommand
@@ -99,9 +101,19 @@ class ConfigCommand(descriptor: PluginDescriptor = ConfigCommandFactory.descript
99101 runCatching {
100102 OrtConfiguration .load(file = this )
101103 }.onSuccess {
102- echo(" The syntax of the configuration file '$this ' is valid." )
104+ echo(Theme .Default .success(" The file '$canonicalPath ' contains valid global ORT configuration." ))
105+ }.recoverCatching {
106+ @Suppress(" TooGenericExceptionCaught" )
107+ try {
108+ readValue<RepositoryConfiguration >()
109+ } catch (t: Throwable ) {
110+ throw t.initCause(it)
111+ }
112+ }.onSuccess {
113+ echo(Theme .Default .success(" The file '$canonicalPath ' contains valid repository ORT configuration." ))
103114 }.onFailure {
104- echo(Theme .Default .danger(it.collectMessages()))
115+ val message = " The file '$canonicalPath ' neither contains valid global nor repository ORT configuration"
116+ echo(Theme .Default .danger(" $message : ${it.collectMessages()} " ))
105117 throw ProgramResult (2 )
106118 }
107119 }
You can’t perform that action at this time.
0 commit comments