开源软件名称(OpenSource Name):leprosus/kotlin-cli开源软件地址(OpenSource Url):https://github.com/leprosus/kotlin-cli开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):kotlin-cliKotlin-CLI - command line option parsing suite for Kotlin Usageimport com.evalab.core.cli.Command
import com.evalab.core.cli.exception.OptionException
fun main(args: Array<String>) {
val command = Command("command", "Command just for testing")
command.addBooleanOption("debug", false, 'd', "Flag of debug mode")
command.addBooleanOption("verbose", false, 'v', "Returns detailed information")
command.addIntegerOption("size", false, 's', "Sets size")
command.addDoubleOption("fraction", false, 'f', "Sets fraction")
command.addStringOption("name", true, 'n', "Sets name")
try {
command.parse(args)
} catch (e: OptionException) {
println(e.message)
println(command.getHelp())
System.exit(2)
}
val debug = command.getBooleanValue("debug", false)
val verbose = command.getBooleanValue("verbose", false)
val size = command.getIntegerValue("size", 0)
val fraction = command.getDoubleValue("fraction", 0.0)
val name = command.getStringValue("name")
println("debug: " + debug)
println("verbose: " + verbose)
println("size: " + size)
println("fraction: " + fraction)
println("name: " + name)
} ContactFollow me @leprosus LicenseMIT License. See the |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论