bump version to 1.4.0

This commit is contained in:
2026-01-05 15:56:14 +01:00
parent 7b9e39f9d0
commit 6779e28792
3 changed files with 34 additions and 33 deletions

View File

@@ -21,46 +21,47 @@ repositories {
}
dependencies {
implementation("com.infendro:cli:1.3.1")
implementation("com.infendro:cli:1.4.0")
}
```
## Usage
```kotlin
fun main(args: Array<String>) {
// declare root command
cli {
fun main(args: Array<String>) = cli {
execute {
// define execution of command (e.g., display help)
}
// declare command "greet"
command("greet") {
// declare arguments
val speakersArg = Argument.strings().register()
// declare options
val greetingOpt = Option.stringOrElse("greeting", "greet", "g", other = "Hello").register()
val nameOpt = Option.stringOrNull("name", "n").register()
execute {
// execution of root command (e.g., display help)
// retrieve the arguments and options
val speakers by speakersArg
val greeting by greetingOpt
val name by nameOpt
println("${speakers.joinToString()}: $greeting ${name ?: "World"}!")
}
// declare command "test"
command("test") {
// declare arguments
val greetingArg = stringOrElse("greeting", "greet", "g", other = "Hello")
val nameArg = stringOrNull("name", "n")
// declare more commands...
}
execute {
// retrieve the arguments
val greeting by greetingArg
val name by nameArg
// declare fallback command
command { valueCmd ->
execute {
// retrieve the value used for the fallback command
val value by valueCmd
println("$greeting ${name ?: "World"}!")
}
// declare more commands...
println("""command "$value" executed!""")
}
// declare wildcard command
command { wildcard ->
execute {
// retrieve the value used for the wildcard command
val value by wildcard
println("command $value executed!")
}
}
}.run(args)
}
}
}.run(args)
```