clikt
clikt copied to clipboard
Env vars are not bound when `CoreCliktCommand` is used
CliktCommand works fine. CoreSuspendingCliktCommand also broken.
Works:
fun main(vararg args: String) {
ExampleCommand().main(args)
}
private const val envVarName = "THIS_IS_A_TEST"
private class ExampleCommand : CliktCommand() {
private val value by option(envvar = envVarName)
override fun run() {
println("env: " + System.getenv(envVarName))
println("property: $value")
}
}
❯ gw -q installDist && THIS_IS_A_TEST=hello ./build/install/clikt-env-vars/bin/clikt-env-vars
env: hello
property: hello
Does not work:
fun main(vararg args: String) {
ExampleCommand().main(args)
}
private const val envVarName = "THIS_IS_A_TEST"
private class ExampleCommand : CoreCliktCommand() {
private val value by option(envvar = envVarName)
override fun run() {
println("env: " + System.getenv(envVarName))
println("property: $value")
}
}
❯ gw -q installDist && THIS_IS_A_TEST=hello ./build/install/clikt-env-vars/bin/clikt-env-vars
env: hello
property: null
Okay so this is documented: https://ajalt.github.io/clikt/advanced/#core-module
However, it seems like Mordant really should not be required for most of these things. Reading env vars in a multiplatform context is a few lines. Reading files is more lines, but not a ridiculous amount of lines. In that list, the only thing that screams Mordant to me is "Text wrapping, formatting, markdown, or color support".
Can we work to move the others into having core support?