:wave: Hi, I'm trying to find a way to mix enum op...
# clikt
s
👋 Hi, I'm trying to find a way to mix enum option using
multiple()
and
prompt()
to allow the user to provide values at runtime if nothing is provided. Unfortunately, this does not seem to be supported. What would be the recommended way to support this kind of behavior? I'm currently using this, but this prevent me from using a prompt
Copy code
val flavors: Set<Flavor> by option("-f", "--flavors")
    .enum<Flavor>(ignoreCase = true)
    .multiple(default = listOf(Main)).unique()
a
That particular combo isn't built in, but you can do it yourself easily.
mutliple
is just
transformAll { it }
, and
prompt
is just
transformAll { it.lastOrNull() ?: terminal.prompt("") }
, so you can combine them like
option().enum<>().transformAll { it.ifEmpty { listOf(terminal.prompt("..."))} }
👀 1
s
Interesting, I'll try that. Thanks a lot. btw, that is an awesome lib that you built 👌
❤️ 1
I'm missing an import resolution on a
getValue
ReadOnlyProperty 🤔
My bad, I forgot to convert it back to a
Set
👍