If I wanted to write a console app in Kotlin, is there a go-to standard CLI parser? I see a few on github, but wondered if there was one just everyone used.
r
Rob Elliot
06/19/2023, 8:39 PM
#clikt is quite popular - not sure if it ranks as go-to standard yet.
Java parsers like picocli also work, and they have examples in Kotlin too. but in my experience Clikt is more common in Kotlin-first projects
m
mcampbell
06/20/2023, 12:06 AM
Will look at these, thanks.
a
Adam S
06/20/2023, 7:04 AM
for some CLI apps I found it easier to pass in a JSON5 file as the only arg (or default to an environment variable) and use Kotlinx Serialization json5k to decode it to a MyCliAppArgs class
I had a vague idea a while ago for using creating a Kotlinx Serialization format for decoding CLI args… https://kotlinlang.slack.com/archives/C7A1U5PTM/p1668606897420759