Skip to content

Commit

Permalink
refactor(requirements): Factor out getting plugins by type
Browse files Browse the repository at this point in the history
Further separate getting information from printing it to improve
testability.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 28, 2023
1 parent 6c90a2e commit fae8600
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ class RequirementsCommand : OrtCommand(
}

private fun listPlugins() {
getPluginsByType().toSortedMap().forEach { (name, all) ->
echo(Theme.Default.info("$name plugins:"))
echo(all.joinToString("\n", postfix = "\n") { "${SUCCESS_PREFIX}$it" })
}
}

private fun getPluginsByType(): Map<String, Set<String>> {
val pluginClasses = reflections.getSubTypesOf(Plugin::class.java)

val pluginTypes = pluginClasses.mapNotNull { clazz ->
Expand All @@ -119,10 +126,7 @@ class RequirementsCommand : OrtCommand(
}
}

pluginTypes.sortedBy { it.first }.forEach { (name, all) ->
echo(Theme.Default.info("$name plugins:"))
echo(all.joinToString("\n", postfix = "\n") { "${SUCCESS_PREFIX}$it" })
}
return pluginTypes.toMap()
}

private fun checkToolVersions(): EnumSet<VersionStatus> {
Expand Down

0 comments on commit fae8600

Please sign in to comment.