Rob Elliot
11/15/2021, 5:24 PMRob Elliot
11/15/2021, 5:24 PMimport com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
data class Config(val username: String)
class CliParser private constructor() : NoOpCliktCommand(
name = "",
help = "help text",
) {
private val username: String by option(help = "the username").required()
private fun toConfig() = Config(username = username)
companion object {
fun parseConfig(vararg args: String): Config =
CliParser()
.apply { parse(args.toList()) }
.toConfig()
}
}