clikt
clikt copied to clipboard
Enum default value does not use key lambda when using showDefaultValues
I have this option:
enum class LogLevel {
DEBUG,
INFO,
WARN,
NONE,
}
val logLevel: LogLevel by option(
"-l",
"--log-level",
help = "Set the log level",
)
.enum<LogLevel> { it.name.lowercase() }
.default(LogLevel.INFO)
When using MordantHelpFormatter(it, showDefaultValues = true), the help message is rendered as:
-l, --log-level=(debug|info|warn|none)
Set the log level (default: INFO)
Ideally, it should be:
-l, --log-level=(debug|info|warn|none)
Set the log level (default: info)
You'll have to do .default(LogLevel.INFO, "info"). Not ideal, but the keys lambda you pass to enum isn't stored anywhere, so there's no way to call it with the default value. To implement that, we'd have to add some valueToString function that gets stored on Options.