implement descriptions, improve default help
This commit is contained in:
12
README.md
12
README.md
@@ -28,20 +28,20 @@ dependencies {
|
||||
## Usage
|
||||
|
||||
```kotlin
|
||||
fun main(args: Array<String>) = command("application") {
|
||||
fun main(args: Array<String>) = command("application", description = "example application") {
|
||||
execute {
|
||||
// define execution of command (e.g., display help)
|
||||
help()
|
||||
}
|
||||
|
||||
// register command "greet"
|
||||
+command("greet") {
|
||||
+command("greet", description = "greet someone") {
|
||||
// declare and register arguments
|
||||
val speakersArg = +argument.string("speakers").variable(min = 1)
|
||||
val speakersArg = +argument.string("speakers", description = "the greeters").variable(min = 1)
|
||||
|
||||
// declare and register options
|
||||
val greetingOpt = +option.string("greeting", "greet", "g").orElse("Hello")
|
||||
val nameOpt = +option.string("name", "n").orNull()
|
||||
val greetingOpt = +option.string("greeting", "greet", "g", description = "the greeting").orElse("Hello")
|
||||
val nameOpt = +option.string("name", "n", description = "the greetee").orNull()
|
||||
|
||||
execute {
|
||||
// retrieve the arguments and options
|
||||
@@ -56,7 +56,7 @@ fun main(args: Array<String>) = command("application") {
|
||||
}
|
||||
|
||||
// register fallback command "value"
|
||||
+command.fallback.string("value") { valueArg ->
|
||||
+command.fallback.string("value", description = "execute an arbitrary command") { valueArg ->
|
||||
execute {
|
||||
// retrieve the value used for the fallback command
|
||||
val value by valueArg
|
||||
|
||||
Reference in New Issue
Block a user