implement descriptions, improve default help

This commit is contained in:
2026-01-09 20:13:19 +01:00
parent 47834c91d8
commit fa0000eba6
9 changed files with 204 additions and 108 deletions

View File

@@ -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()
// 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