Skip to content

CommandLineProcessor

Jens Klingenberg edited this page Aug 11, 2019 · 1 revision

This is an entry point for the compiler plugin. It can read command line arguments which are passed to it.

Extend the CommandLineProcessor class.

class NativeCommandLineProcessor : CommandLineProcessor {

    override val pluginId: String = "helloWorldPlugin"

    override val pluginOptions: Collection<CliOption> = listOf(
        CliOption(
            optionName = "enabled", valueDescription = "<true|false>",
            description = "whether to enable the plugin or not"
        )
    )

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

}
Clone this wiki locally