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
@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.