2026-01-05 15:56:14 +01:00
2025-12-13 01:53:00 +01:00
2025-12-13 01:47:38 +01:00
2025-07-12 20:15:32 +02:00
2026-01-05 15:56:14 +01:00
2025-08-17 21:34:42 +02:00
2025-08-17 21:34:42 +02:00
2025-07-12 20:15:32 +02:00
2026-01-05 15:56:14 +01:00
2025-12-13 01:47:38 +01:00

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.

repositories {
    maven("https://git.infendro.com/api/packages/Infendro/maven")
}

dependencies {
    implementation("com.infendro:cli:1.4.0")
}

Usage

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 {
            // retrieve the arguments and options
            val speakers by speakersArg
            val greeting by greetingOpt
            val name by nameOpt

            println("${speakers.joinToString()}: $greeting ${name ?: "World"}!")
        }

        // declare more commands...
    }

    // declare fallback command
    command { valueCmd ->
        execute {
            // retrieve the value used for the fallback command
            val value by valueCmd

            println("""command "$value" executed!""")
        }
    }
}.run(args)
Description
No description provided
Readme 330 KiB
Languages
Kotlin 100%