Support for Quoted String and Flag
PR:
- [x] #311
- [x] #314
- [x] #325
Issues:
- [x] #316
- [x] #324
- [ ] #219
I am migrating the framework for command content on a large server project to this project, but I found that it lacks support for Quoted and Flag, and I am not sure if the shortcut annotation supports quick registration of commands with spaces. Here is my examples
/prefix set "§cA §bPrefix"
/tag prefix set "§eB §bPrefix" --updateNow
@Command(name = "tag")
class TaqCommand {
@Execute(name = "prefix")
@Shortcut("prefix set")
fun prefix(@Context user: User, @Arg @Quoted prefix: String, @Flag updateNow: Boolean) {
/*
/tag prefix set "§eB §bPrefix" --updateNow
prefix = "§eB §bPrefix"
updateNow = true
*/
/*
/prefix set "§cA §bPrefix"
prefix = "A §bPrefix"
updateNow = false
*/
}
}
At the same time, I also hope that Flag annotations are not limited to Boolean, but directly support parsing registered arguments. The following are relevant examples
@Command(name = "flagTest")
class FlagTest {
/*
/flagTest --enable
message: Enabled: true
/flagTest
message: Enabled: false
*/
@Execute
fun bool(@Context user: User, @Flag enable: Boolean) {
user.sendMessage("Enabled: $enable")
}
/*
/flagTest --text LiteCommands3
message: Text: LiteCommands
/flagTest --text LiteCommands3 --world generated-lobby-1
message:
Text: LiteCommands
World: generated-lobby-1
*/
@Execute
fun str(@Context user: User, @Flag text: String, @Flag world: World?) {
user.sendMessage("Text: $text")
if (world != null) user.sendMessage("World: $world")
}
}
Hi @huanmeng-qwq, thanks for your feedback.
Introducing @Quoted feature would be a highly beneficial solution, and I suppose it will be introduced soon. Currently @Shortcut don't support spaces in the name, but it is also a feature that we need to add.
The @Flag annotation does not support other types such as String or Integer, for this moment we are using @Arg Optional<String> to create optional arguments. https://github.com/Rollczi/LiteCommands/issues/219
I have seen the branches related to quoted strings, and I would like to propose a new suggestion based on #314 , which is to support input of '. When players want to input", they can use '"' to surround it, and vice versa
e.g: /quoted "huanmeng-qwq's Pet" or /quoted 'my name "huanmeng-qwq"'
I know to add optional parameters to @Arg Optional<String>, but it's different from @Flag. @Flag can specify the value of a certain parameter, while @Arg needs to input in the order of the code
Of course, I also hope to be able to develop complete Flag features as quickly as possible
I have seen the branches related to quoted strings, and I would like to propose a new suggestion based on #314 , which is to support input of
'. When players want to input", they can use'"'to surround it, and vice versa e.g:/quoted "huanmeng-qwq's Pet"or/quoted 'my name "huanmeng-qwq"'
Now a solution to this problem is \"
Yes, I have also considered using escape, which is a great implementation!
- [x]
@Quoted - [ ]
@Flag - [x]
@Shortcutspaces in the name