random thought: what about a Kotlinx Serialization...
# serialization
a
random thought: what about a Kotlinx Serialization format that encoded to/from command line arguments? So you could map between command line arguments and data classes
--log-level INFO --repeat 3 --dry-run
Copy code
@Serializable
data class Args(
  @SerialName("log-level")
  val logLevel : LogLevel,

  val repeat: UInt = 1,

  @SerialName("dry-run")
  val dryRun: Boolean,
)
It would be kind of like the type-safe routing in Ktor, or instead of
parseSpaceSeparatedArgs()
and a more hackable version of kotlinx-cli. The usage mostly being to parse
fun main(args: Array<String>) {}
, but it could also be used to wrap existing CLI tools, so they can be called from Kotlin (and Gradle), type-safely.
1
o
I've been using https://ajalt.github.io/clikt/ for command line parsing and https://ajalt.github.io/mordant/ for text styling and progress bars. Found both of them super useful.
c
If you like Compose, Mosaic (https://github.com/JakeWharton/mosaic) is also pretty good