All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.molumn.catrix.kommand.ArgumentNode.kt Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
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