Revxrsal / Lamp

A modern annotations-driven commands framework for Java and Kotlin
MIT License
202 stars 38 forks source link

feat: Flag and Switch aliases #41

Closed gmitch215 closed 1 year ago

gmitch215 commented 1 year ago

Hello,

A neat suggestion I think would be nice for Lamp is the option for @Flag and @Switch annotations to support aliases. I'm unsure if this is natively supported by brigadier since I've never worked with commands before, but it would be cool to use.

Perhaps the inputted array could override all of the names for the switch/flag, or add on upon the inputted parameter name (that could be an option in the CommandHandler). The original message is available on the Lamp Discord.

Something like this:

public void send(Player sender, @Flag({"sendtype", "sendingtype", "st"}) SendType type, @Switch({"broadcast", "sendall"}) boolean sendAll) {
   // ...
}

@SkytAsul (their original message) also recommended the option to mix flags and/or switches together, as in some Unix commands, such as:

rm -r -f
# Becomes...
rm -rf

Thanks!

Revxrsal commented 1 year ago

Thank you for the suggestion. This is planned, but I can't give any promises when it will be ready. I'll leave the issue open in the meantime.

gmitch215 commented 1 year ago

Any updates on this?

Revxrsal commented 1 year ago

To be honest, I'm not sure if this would align well with the overall (strict) design of Lamp. This would easily mess up command completions and make the process of finding commands a lot harder. Also, considering the fact that Lamp attempts to 100% incorporate with Brigadier, this wouldn't work as Brigadier doesn't have the idea of flags and switches, and attempts to bypass that would lead to undesired results (e.g. having to see all possible outputs at once, -r, -rf, -f, -r -f even though you wouldn't need them)

Unfortunately, Lamp wasn't built on the convention of Unix commands, rather Minecraft ones, which may require a shift in mindset when using it.