Infendro 79629ae68d refactor argument system
- arguments can have multiple names simultaneously
- argument values can be passed using spaces (e.g., --arg value)
- single-character arguments can be passed using a single dash (e.g., --a -> -a)
- multiple single-character arguments can be combined (e.g., -a -b -> -ab)
- simplify custom arguments using generic classes
2025-12-27 17:30:05 +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
2025-12-13 01:47:38 +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
2025-12-13 20:24:01 +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.3.0")
}

Usage

import com.infendro.cli.argument.stringOrElse
import com.infendro.cli.argument.stringOrNull
import com.infendro.cli.command.cli

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", "Hello")
            val nameArg = stringOrNull("name")

            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)
}
Description
No description provided
Readme 330 KiB
Languages
Kotlin 100%