kotlin import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.options.option class HelloWorldCommand : CliktCommand() { private val name: String by argument() private val repeat by option("-r", "--repeat", help = "Number of times to repeat").int().default(1) override fun run() { repeat(repeat) { echo("Hello, $name!") } } } fun main(args: Array<String>) = HelloWorldCommand().main(args) $ hello-world Alice --repeat=3 Hello, Alice! Hello, Alice! Hello, Alice!


上一篇:
下一篇:
切换中文