Subcommand after argument
Matt-MX opened this issue · 1 comments
Matt-MX commented
Currently declarative command builder doesn't allow for defining a subcommand/enum choice after an argument.
val a by doubleArgument()
val b by doubleArgument()
("math" / a / listOf(
"add".runs<Player> { reply(!"&a${a()} + ${b()} = ${a() + b()}") },
"sub".runs<Player> { reply(!"&a${a()} - ${b()} = ${a() - b()}") },
"mul".runs<Player> { reply(!"&a${a()} * ${b()} = ${a() * b()}") },
"div".runs<Player> { reply(!"&a${a()} / ${b()} = ${a() / b()}") },
) / b) register this
This syntax is not final and is just an example.
Matt-MX commented
Might not be an issue since we can just treat these "subcommands" as multi-args
e.g
val choices by multiChoiceArgument<(Double, Double) -> Double>(
"add" to { a, b -> a + b },
"sub" to { a, b -> a - b },
"mul" to { a, b -> a * b },
"div" to { a, b -> a / b },
)
("math" / a / choices / b) {
runs<Player> {
reply(!"&a${choices(a(), b())}")
}
}