Created
November 21, 2020 19:10
-
-
Save bnorm/b5fbcec7adb7b09af4a1f20d46bf3d2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AutoService(CommandLineProcessor::class) | |
class TemplateCommandLineProcessor : CommandLineProcessor { | |
companion object { | |
private const val OPTION_STRING = "string" | |
private const val OPTION_FILE = "file" | |
val ARG_STRING = CompilerConfigurationKey<String>(OPTION_STRING) | |
val ARG_FILE = CompilerConfigurationKey<String>(OPTION_FILE) | |
} | |
override val pluginId: String = BuildConfig.KOTLIN_PLUGIN_ID | |
override val pluginOptions: Collection<CliOption> = listOf( | |
CliOption( | |
optionName = OPTION_STRING, | |
valueDescription = "string", | |
description = "sample string argument", | |
required = false, | |
), | |
CliOption( | |
optionName = OPTION_FILE, | |
valueDescription = "file", | |
description = "sample file argument", | |
required = false, | |
), | |
) | |
override fun processOption( | |
option: AbstractCliOption, | |
value: String, | |
configuration: CompilerConfiguration | |
) { | |
return when (option.optionName) { | |
OPTION_STRING -> configuration.put(ARG_STRING, value) | |
OPTION_FILE -> configuration.put(ARG_FILE, value) | |
else -> throw IllegalArgumentException("Unexpected config option ${option.optionName}") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment