Skip to content
Kotlin · JVM · Zero dependenciesv0.1.2

Typed command-line parsing, without the ceremony.

Declare your parameters once and get validated values at startup. No runtime reflection, no third-party dependencies.

implementation("org.draftcode:argot-core:0.1.2")
GreetArgs.ktsource
import org.draftcode.argot.Arguments

class GreetArgs : Arguments(
    programName = "greet",
    description = "Print a friendly greeting.",
) {
    val name: String by option("--name", "-n", help = "Who to greet").default("world")
    val count: Int by option("--count", "-c", help = "How many times").int().default(1)
    val loud: Boolean by flag("--loud", "-l", help = "Shout the greeting")
}

The same program, declared both ways, and the help screen Argot generates from it.

§ 01 — Why

Three promises, kept by the compiler.

  1. 01

    Two styles, one engine

    Plain Kotlin delegates, or annotate a data class and let a KSP processor write the parser. Both build the same specification and run the same engine, so behaviour and help output are identical.

  2. 02

    Nothing at runtime

    argot-core and argot-annotations depend only on the Kotlin standard library. KSP and KotlinPoet never reach your runtime classpath, and there is no classpath scan at startup.

  3. 03

    Errors at compile time

    Duplicate names, misplaced positionals and unsupported types are reported while you build, not when a user runs your program.

§ 02 — Install

One dependency to start.

argot-core is the whole delegate API — nothing else to add, nothing to configure. The annotation style needs two more artifacts and the KSP plugin.

build.gradle.kts
dependencies {
    implementation("org.draftcode:argot-core:0.1.2")
}

// Only for the annotation style:
plugins {
    id("com.google.devtools.ksp") version "2.3.11"
}

dependencies {
    implementation("org.draftcode:argot-annotations:0.1.2")
    ksp("org.draftcode:argot-processor:0.1.2")
}

Released under the Apache License 2.0.