All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.jensklingenberg.ktorfit.ExampleCommandLineProcessor.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-2.1.0
Show newest version
package de.jensklingenberg.ktorfit

import com.google.auto.service.AutoService
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption
import org.jetbrains.kotlin.compiler.plugin.CliOption
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.CompilerConfigurationKey

@AutoService(CommandLineProcessor::class) // don't forget!
class ExampleCommandLineProcessor : CommandLineProcessor {

    override val pluginId: String = "ktorfitPlugin"

    override val pluginOptions: Collection = listOf(
        CliOption(
            optionName = "enabled", valueDescription = "",
            description = "whether to enable the plugin or not"
        ),
        CliOption(
            optionName = "logging", valueDescription = "",
            description = "whether to enable logging"
        )
    )

    override fun processOption(
        option: AbstractCliOption,
        value: String,
        configuration: CompilerConfiguration
    ) = when (option.optionName) {
        "enabled" -> configuration.put(KEY_ENABLED, value.toBoolean())
        "logging" -> configuration.put(KEY_LOGGING, value.toBoolean())
        else -> configuration.put(KEY_ENABLED, true)
    }
}

val KEY_ENABLED = CompilerConfigurationKey("whether the plugin is enabled")
val KEY_LOGGING = CompilerConfigurationKey("whether logging is enabled")




© 2015 - 2025 Weber Informatics LLC | Privacy Policy