Skip to content

Commit

Permalink
Update dependency com.github.ajalt.clikt:clikt to v5 (#903)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Wendland, Florian <[email protected]>
  • Loading branch information
renovate[bot] and fwendland authored Sep 20, 2024
1 parent 8a44f75 commit 0259565
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package de.fraunhofer.aisec.codyze.backends.cpg
import com.github.ajalt.clikt.core.BadParameterValue
import com.github.ajalt.clikt.core.MultiUsageError
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.parse
import com.github.ajalt.clikt.parameters.groups.provideDelegate
import de.fraunhofer.aisec.codyze.core.config.combineSources
import de.fraunhofer.aisec.cpg.passes.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.findOrSetObject
import com.github.ajalt.clikt.output.MordantHelpFormatter
Expand Down Expand Up @@ -51,7 +51,10 @@ fun CliktCommand.configFileOption() =
* config[[Path]] as context to the [[CodyzeCli]] command.
*/
@Suppress("Unused")
class ConfigFileParser : CliktCommand(treatUnknownOptionsAsArgs = true) {
class ConfigFileParser : CliktCommand() {

override val treatUnknownOptionsAsArgs: Boolean = true

val configFile: Path by configFileOption()

// necessary when using 'treatUnknownOptionsAsArgs'. Contains all given arguments except for configFile
Expand All @@ -70,11 +73,17 @@ class ConfigFileParser : CliktCommand(treatUnknownOptionsAsArgs = true) {
*/
@Suppress("Unused", "UnusedPrivateMember")
class CodyzeCli(val configFile: Path?) :
NoOpCliktCommand(
help = "Codyze finds security flaws in source code",
printHelpOnEmptyArgs = true,
allowMultipleSubcommands = true
) {
CliktCommand() {

/*
* Configure Clikt command
*/
override val printHelpOnEmptyArgs: Boolean = true
override val allowMultipleSubcommands: Boolean = true

override fun help(context: Context): String {
return "Codyze finds security flaws in source code"
}

init {
versionOption(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.core.parse
import com.github.ajalt.clikt.core.subcommands
import de.fraunhofer.aisec.codyze.core.backend.BackendCommand
import de.fraunhofer.aisec.codyze.core.executor.ExecutorCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.parse
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.options.multiple
import com.github.ajalt.clikt.parameters.options.option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package de.fraunhofer.aisec.codyze.cli

import com.github.ajalt.clikt.core.BadParameterValue
import com.github.ajalt.clikt.core.parse
import de.fraunhofer.aisec.codyze.core.output.SarifBuilder
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ import kotlin.reflect.KClass
* This abstract class must be implemented by all [Backend]s that want to be selectable in the codyze-cli.
* Remember to add the newly created [BackendCommand] to the dependency injection.
*/
abstract class BackendCommand<T : Backend>(cliName: String? = null) : NoOpCliktCommand(hidden = true, name = cliName) {
abstract class BackendCommand<T : Backend>(cliName: String? = null) : NoOpCliktCommand(name = cliName) {

/*
* Configure Clikt command
*/
override val hiddenFromHelp: Boolean = true

abstract val backend: KClass<T>
abstract fun getBackend(): T
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ import org.koin.java.KoinJavaComponent.getKoin
* Remember to add the newly created [ExecutorCommand] to the dependency injection.
*/
abstract class ExecutorCommand<T : Executor>(cliName: String? = null) :
NoOpCliktCommand(hidden = true, name = cliName) {
CliktCommand(name = cliName) {

/*
* Configure Clikt command
*/
override val hiddenFromHelp: Boolean = true

/** Use the global context set in [CodyzeCli] */
private val usedExecutors by findOrSetObject { mutableListOf<ExecutorCommand<*>>() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package de.fraunhofer.aisec.codyze.core.plugin

import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.groups.provideDelegate
import de.fraunhofer.aisec.codyze.core.output.aggregator.Aggregate
import de.fraunhofer.aisec.codyze.core.output.aggregator.extractLastRun
Expand All @@ -34,7 +34,13 @@ val logger = KotlinLogging.logger { }
* Also, remember to add a page to docs/plugins.
*/
abstract class Plugin(private val cliName: String) :
NoOpCliktCommand(hidden = true, name = cliName) {
CliktCommand(name = cliName) {

/*
* Configure Clikt command
*/
override val hiddenFromHelp: Boolean = true

private val options by PluginOptionGroup(cliName)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package de.fraunhofer.aisec.codyze.specificationLanguages.coko.dsl.cli

import com.github.ajalt.clikt.core.parse
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cpg-language-java = { module = "de.fraunhofer.aisec:cpg-language-java", version.

kotlin-logging = { module = "io.github.oshai:kotlin-logging-jvm", version = "7.0.0" }
log4j-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version = "2.24.0"}
clikt = { module = "com.github.ajalt.clikt:clikt", version = "4.4.0"}
clikt = { module = "com.github.ajalt.clikt:clikt", version = "5.0.0"}
koin = { module = "io.insert-koin:koin-core", version.ref = "koin"}
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin-test"}
koin-junit5 = { module = "io.insert-koin:koin-test-junit5", version.ref = "koin-test"}
Expand Down

0 comments on commit 0259565

Please sign in to comment.