implement automatic help
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user