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 {
// execution of root command (e.g., display help)
// define execution of command (e.g., display help)
}
// declare command "test"
command("test") {
// declare command "greet"
command("greet") {
// declare arguments
val greetingArg = stringOrElse("greeting", "greet", "g", other = "Hello")
val nameArg = stringOrNull("name", "n")
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 {
// retrieve the arguments
val greeting by greetingArg
val name by nameArg
// retrieve the arguments and options
val speakers by speakersArg
val greeting by greetingOpt
val name by nameOpt
println("$greeting ${name ?: "World"}!")
println("${speakers.joinToString()}: $greeting ${name ?: "World"}!")
}
// declare more commands...
}
// declare wildcard command
command { wildcard ->
// declare fallback command
command { valueCmd ->
execute {
// retrieve the value used for the wildcard command
val value by wildcard
// retrieve the value used for the fallback command
val value by valueCmd
println("command $value executed!")
println("""command "$value" executed!""")
}
}
}.run(args)
}
```

View File

@@ -2,7 +2,7 @@ import com.infendro.plugin.infendro
import com.infendro.plugin.token
group = "com.infendro"
version = "1.3.1"
version = "1.4.0"
plugins {
alias(libs.plugins.infendro)

View File

@@ -10,8 +10,8 @@ import com.infendro.cli.util.Regex.OPTION
class Command private constructor(
val name: String?,
val commands: List<Command>,
val options: List<Option<*>>,
val arguments: List<Argument<*>>,
val options: List<Option<*>>,
internal val execute: Context.() -> Unit,
) {
val fallback: Boolean
@@ -97,7 +97,7 @@ class Command private constructor(
if (!::_execute.isInitialized)
_execute = {}
return Command(name, commands, options, arguments, _execute)
return Command(name, commands, arguments, options, _execute)
}
}