implement type-safe fallback commands
This commit is contained in:
@@ -37,11 +37,11 @@ fun main(args: Array<String>) = cli("application") {
|
||||
// declare command "greet"
|
||||
command("greet") {
|
||||
// declare arguments
|
||||
val speakersArg by Argument.string("speakers").variable(min = 1)
|
||||
val speakersArg by argument.string("speakers").variable(min = 1)
|
||||
|
||||
// declare options
|
||||
val greetingOpt by Option.string("greeting", "greet", "g").orElse("Hello")
|
||||
val nameOpt by Option.string("name", "n").orNull()
|
||||
val greetingOpt by option.string("greeting", "greet", "g").orElse("Hello")
|
||||
val nameOpt by option.string("name", "n").orNull()
|
||||
|
||||
execute {
|
||||
// retrieve the arguments and options
|
||||
@@ -56,7 +56,7 @@ fun main(args: Array<String>) = cli("application") {
|
||||
}
|
||||
|
||||
// declare fallback command
|
||||
fallback("value") { valueArg ->
|
||||
fallback.string("value") { valueArg ->
|
||||
execute {
|
||||
// retrieve the value used for the fallback command
|
||||
val value by valueArg
|
||||
|
||||
Reference in New Issue
Block a user