io.github.molumn.catrix.kommand.ArgumentNode.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of catrix-api Show documentation
Show all versions of catrix-api Show documentation
Kotlin/JVM library for terminal command development
package io.github.molumn.catrix.kommand
import io.github.molumn.catrix.annotations.KommandDSL
import io.github.molumn.catrix.common.Interactive
import io.github.molumn.catrix.kommand.node.NodeType
import io.github.molumn.catrix.utils.FakeSystem
@KommandDSL
class ArgumentNode(
name: String,
private val type: NodeType
) : AbstractKommandNode(name) {
override fun build(): AbstractRegisteredKommandNode {
return RegisteredArgumentNode(name, type, condition, executor, children.map { it.build() })
}
}
class RegisteredArgumentNode(
name: String,
private val type: NodeType,
condition: FakeSystem.() -> Boolean,
executor: ((Interactive, KommandContext, FakeSystem) -> Boolean)?,
children: List>
) : AbstractRegisteredKommandNode(name, condition, executor, children) {
override fun check(string: String): Boolean = type.check(string)
override fun extract(string: String): T = type.extract(string)
override fun listSuggestion(string: String): List = type.listSuggestions(string)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy