Michael Friend
01/14/2025, 8:08 PMclass Pickle : SuspendingCliktCommand() {
val config by option(eager = true)
.file()
init {
context {
config?.let {
valueSources(PropertiesValueSource.from(it))
}
}
}
val test by option()
override suspend fun run() {
echo(test)
}
}
Michael Friend
01/14/2025, 8:16 PM.defaultLazy
seems to almost do what i need with a slightly better api than transformAll but it doesnt allow returning null as a default which ill need in some cases. Basically what i want is for the option to get its value in priority order of: command arg -> config file -> some static default (maybe null).
val config by option()
.file()
val test by option(valueSourceKey = "test")
.transformAll {
it.lastOrNull() ?: config?.let {
PropertiesValueSource.from(it).getValues(this.context, this.option).first().values.first()
}
?: "default"
}
AJ Alt
02/09/2025, 7:16 PM