io.github.molumn.catrix.kommand.LiteralNode.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.utils.FakeSystem
@KommandDSL
class LiteralNode(name: String) : AbstractKommandNode(name) {
override fun build(): AbstractRegisteredKommandNode<*> {
return RegisteredLiteralNode(name, condition, executor, children.map { it.build() })
}
}
class RegisteredLiteralNode(
name: String,
condition: FakeSystem.() -> Boolean,
executor: ((Interactive, KommandContext, FakeSystem) -> Boolean)?,
children: List>
) : AbstractRegisteredKommandNode(name, condition, executor, children) {
override fun check(string: String): Boolean = string == name
override fun extract(string: String): String {
require(string == name) { "not matched content: $string to $name" }
return string
}
override fun listSuggestion(string: String): List = listOf(name)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy