All checks were successful
/ publish (push) Successful in 3m50s
update README to match changes
67 lines
1.5 KiB
Markdown
67 lines
1.5 KiB
Markdown
# cli-kt
|
|
|
|
`cli-kt` is a Kotlin Multiplatform framework for implementing terminal applications.
|
|
|
|
## Targets
|
|
|
|
| Target | Status |
|
|
|------------------|---------------|
|
|
| JVM | Supported |
|
|
| JavaScript | Supported |
|
|
| Native (Linux) | Supported |
|
|
| Native (Windows) | Not Supported |
|
|
|
|
## Installation
|
|
|
|
Add the following to your `build.gradle.kts`.
|
|
|
|
```kotlin
|
|
repositories {
|
|
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
|
}
|
|
|
|
dependencies {
|
|
implementation("com.infendro:cli:1.3.1")
|
|
}
|
|
```
|
|
|
|
## Usage
|
|
|
|
```kotlin
|
|
fun main(args: Array<String>) {
|
|
// declare root command
|
|
cli {
|
|
execute {
|
|
// execution of root command (e.g., display help)
|
|
}
|
|
|
|
// declare command "test"
|
|
command("test") {
|
|
// declare arguments
|
|
val greetingArg = stringOrElse("greeting", "greet", "g", other = "Hello")
|
|
val nameArg = stringOrNull("name", "n")
|
|
|
|
execute {
|
|
// retrieve the arguments
|
|
val greeting by greetingArg
|
|
val name by nameArg
|
|
|
|
println("$greeting ${name ?: "World"}!")
|
|
}
|
|
|
|
// declare more commands...
|
|
}
|
|
|
|
// declare wildcard command
|
|
command { wildcard ->
|
|
execute {
|
|
// retrieve the value used for the wildcard command
|
|
val value by wildcard
|
|
|
|
println("command $value executed!")
|
|
}
|
|
}
|
|
}.run(args)
|
|
}
|
|
```
|