implement automatic help

This commit is contained in:
2026-01-07 18:53:35 +01:00
parent 4e9b358ef8
commit ecd255479a
18 changed files with 277 additions and 88 deletions

View File

@@ -10,8 +10,8 @@ import kotlin.reflect.KProperty
class Context internal constructor(
val command: Command,
val commands: List<Cmd>,
val options: List<Opt>,
val arguments: List<Arg>,
val options: List<Opt>,
) {
class Cmd(
val name: String,
@@ -28,6 +28,10 @@ class Context internal constructor(
internal fun execute() = (command.execute)()
fun help() {
command.help?.let { println(it) }
}
operator fun Command.Key.getValue(thisRef: Any?, property: KProperty<*>): String = commands[index].name
private val <T : Any> Argument<T>.index: Int