Skip to content

Commit 1f854fb

Browse files
mnonnenmachersschuberth
authored andcommitted
feat(requirements): Remove listing plugins from the RequirementsCommand
Remove the option to list plugins from the `RequirementsCommand` as now all plugins are listed by the `PluginsCommand` [1]. Also update places that refer to the old command to use the plugins command instead. [1]: #9140 (comment) Signed-off-by: Martin Nonnenmacher <[email protected]>
1 parent 66b03c5 commit 1f854fb

File tree

7 files changed

+6
-65
lines changed

7 files changed

+6
-65
lines changed

.github/ISSUE_TEMPLATE/bug.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ No screenshots of plain text please, to keep text searchable.
3434

3535
### Environment
3636

37-
Output of the `ort requirements -l commands` command:
37+
Output of the `ort requirements` command:
3838

3939
```
4040
<copy & paste console output to here; no screenshots please>

cli/src/main/dist/plugin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Put the JARs (and their dependencies) for any custom ORT plugins into this directory for ORT to load them at runtime.
22

3-
Afterward, you can run `ort requirements --list plugins` to verify that they have been properly loaded by ORT.
3+
Afterward, you can run `ort plugins` to verify that they have been properly loaded by ORT.

integrations/completions/ort-completion.bash

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,12 +1279,6 @@ _ort_requirements() {
12791279
(( i = i + 1 ));
12801280
continue
12811281
;;
1282-
--list|-l)
1283-
__skip_opt_eq
1284-
(( i = i + 1 ))
1285-
[[ ${i} -gt COMP_CWORD ]] && in_param='--list' || in_param=''
1286-
continue
1287-
;;
12881282
-h|--help)
12891283
__skip_opt_eq
12901284
in_param=''
@@ -1302,7 +1296,7 @@ _ort_requirements() {
13021296
done
13031297
local word="${COMP_WORDS[$COMP_CWORD]}"
13041298
if [[ "${word}" =~ ^[-] ]]; then
1305-
COMPREPLY=($(compgen -W '--list -l -h --help' -- "${word}"))
1299+
COMPREPLY=($(compgen -W '-h --help' -- "${word}"))
13061300
return
13071301
fi
13081302
@@ -1312,9 +1306,6 @@ _ort_requirements() {
13121306
[[ -z "${in_param}" ]] && in_param=${vararg_name}
13131307
13141308
case "${in_param}" in
1315-
"--list")
1316-
COMPREPLY=($(compgen -W 'PLUGINS COMMANDS' -- "${word}"))
1317-
;;
13181309
"--help")
13191310
;;
13201311
esac

integrations/completions/ort-completion.fish

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ complete -c ort -n "__fish_seen_subcommand_from report" -s h -l help -d 'Show th
166166
complete -c ort -f -n __fish_use_subcommand -a requirements -d 'Check for the command line tools required by ORT.'
167167

168168
## Options for requirements
169-
complete -c ort -n "__fish_seen_subcommand_from requirements" -l list -s l -r -fa "PLUGINS COMMANDS" -d 'A comma-separated list of requirements to list.'
170169
complete -c ort -n "__fish_seen_subcommand_from requirements" -s h -l help -d 'Show this message and exit'
171170

172171

integrations/completions/ort-completion.zsh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,12 +1284,6 @@ _ort_requirements() {
12841284
(( i = i + 1 ));
12851285
continue
12861286
;;
1287-
--list|-l)
1288-
__skip_opt_eq
1289-
(( i = i + 1 ))
1290-
[[ ${i} -gt COMP_CWORD ]] && in_param='--list' || in_param=''
1291-
continue
1292-
;;
12931287
-h|--help)
12941288
__skip_opt_eq
12951289
in_param=''
@@ -1307,7 +1301,7 @@ _ort_requirements() {
13071301
done
13081302
local word="${COMP_WORDS[$COMP_CWORD]}"
13091303
if [[ "${word}" =~ ^[-] ]]; then
1310-
COMPREPLY=($(compgen -W '--list -l -h --help' -- "${word}"))
1304+
COMPREPLY=($(compgen -W '-h --help' -- "${word}"))
13111305
return
13121306
fi
13131307
@@ -1317,9 +1311,6 @@ _ort_requirements() {
13171311
[[ -z "${in_param}" ]] && in_param=${vararg_name}
13181312
13191313
case "${in_param}" in
1320-
"--list")
1321-
COMPREPLY=($(compgen -W 'PLUGINS COMMANDS' -- "${word}"))
1322-
;;
13231314
"--help")
13241315
;;
13251316
esac

integrations/jenkins/Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ pipeline {
375375
ORT_OPTIONS="$ORT_OPTIONS --stacktrace"
376376
fi
377377
378-
/opt/ort/bin/ort $ORT_OPTIONS requirements --list plugins
378+
/opt/ort/bin/ort $ORT_OPTIONS plugins
379379
'''.stripIndent().trim()
380380
}
381381
}

plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@
2020
package org.ossreviewtoolkit.plugins.commands.requirements
2121

2222
import com.github.ajalt.clikt.core.ProgramResult
23-
import com.github.ajalt.clikt.parameters.options.default
24-
import com.github.ajalt.clikt.parameters.options.option
25-
import com.github.ajalt.clikt.parameters.options.split
26-
import com.github.ajalt.clikt.parameters.types.enum
2723
import com.github.ajalt.mordant.rendering.Theme
2824

2925
import java.io.File
3026
import java.lang.reflect.Modifier
3127
import java.util.EnumSet
3228

33-
import kotlin.reflect.full.companionObjectInstance
34-
3529
import org.apache.logging.log4j.kotlin.logger
3630

3731
import org.ossreviewtoolkit.analyzer.PackageManager
@@ -42,7 +36,6 @@ import org.ossreviewtoolkit.plugins.api.PluginDescriptor
4236
import org.ossreviewtoolkit.plugins.commands.api.OrtCommand
4337
import org.ossreviewtoolkit.plugins.commands.api.OrtCommandFactory
4438
import org.ossreviewtoolkit.utils.common.CommandLineTool
45-
import org.ossreviewtoolkit.utils.common.Plugin
4639
import org.ossreviewtoolkit.utils.common.enumSetOf
4740
import org.ossreviewtoolkit.utils.spdx.scanCodeLicenseTextDir
4841

@@ -64,8 +57,6 @@ private val SUCCESS_PREFIX = "\t${Theme.Default.success("*")} "
6457
class RequirementsCommand(
6558
descriptor: PluginDescriptor = RequirementsCommandFactory.descriptor
6659
) : OrtCommand(descriptor) {
67-
private enum class RequirementsType { PLUGINS, COMMANDS }
68-
6960
private enum class VersionStatus {
7061
/** The determined version satisfies ORT's requirements. */
7162
SATISFIED,
@@ -80,17 +71,10 @@ class RequirementsCommand(
8071
UNAVAILABLE
8172
}
8273

83-
private val list by option(
84-
"--list", "-l",
85-
help = "A comma-separated list of requirements to list."
86-
).enum<RequirementsType>().split(",").default(RequirementsType.entries)
87-
8874
private val reflections by lazy { Reflections("org.ossreviewtoolkit", Scanners.SubTypes) }
8975

9076
override fun run() {
91-
if (RequirementsType.PLUGINS in list) listPlugins()
92-
93-
val status = if (RequirementsType.COMMANDS in list) checkToolVersions() else enumSetOf(VersionStatus.SATISFIED)
77+
val status = checkToolVersions()
9478

9579
echo("Prefix legend:")
9680
echo("${DANGER_PREFIX}The tool was not found in the PATH environment.")
@@ -127,30 +111,6 @@ class RequirementsCommand(
127111
}
128112
}
129113

130-
private fun listPlugins() {
131-
getPluginsByType().toSortedMap().forEach { (name, all) ->
132-
echo(Theme.Default.info("$name plugins:"))
133-
echo(all.joinToString("\n", postfix = "\n") { "${SUCCESS_PREFIX}$it" })
134-
}
135-
}
136-
137-
internal fun getPluginsByType(): Map<String, Set<String>> {
138-
val pluginClasses = reflections.getSubTypesOf(Plugin::class.java)
139-
140-
val pluginTypes = pluginClasses.mapNotNull { clazz ->
141-
val companion = clazz.declaredClasses.find { it.name.endsWith("\$Companion") }
142-
val all = runCatching { companion?.getDeclaredMethod("getALL") }.getOrNull()
143-
144-
all?.let {
145-
@Suppress("UNCHECKED_CAST")
146-
val plugins = all.invoke(clazz.kotlin.companionObjectInstance) as Map<String, *>
147-
clazz.simpleName to plugins.keys
148-
}
149-
}
150-
151-
return pluginTypes.toMap()
152-
}
153-
154114
private fun checkToolVersions(): EnumSet<VersionStatus> {
155115
// Toggle bits in here to denote the kind of error. Skip the first bit as status code 1 is already used above.
156116
val overallStatus = enumSetOf<VersionStatus>()

0 commit comments

Comments
 (0)