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")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
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.
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.
Duplicate names, misplaced positionals and unsupported types are reported while you build, not when a user runs your program.
§ 02 — Install
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.
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")
}