Skip to content

Better CommandHandler#152

Open
Zelaux wants to merge 7 commits into
Anuken:masterfrom
Zelaux:better-command-handler
Open

Better CommandHandler#152
Zelaux wants to merge 7 commits into
Anuken:masterfrom
Zelaux:better-command-handler

Conversation

@Zelaux

@Zelaux Zelaux commented Aug 22, 2023

Copy link
Copy Markdown

Added:

  1. possibility to use spaces in param names
  2. possibility to write required params after optional
  3. variadic params may not be at the end
  4. better exceptions

Added Tests for params parser and splitter

@Anuken

Anuken commented Aug 22, 2023

Copy link
Copy Markdown
Owner

General comments:

  • Is all this complexity really necessary? 4 extra files for command parsing...?
  • Are these changes really necessary at all?
    • Spaces in param names is a minor convenience, yes.
    • Why? This is very confusing. As a comparison, programming languages don't support this in methods, and for good reason. (C#: Optional parameters must appear after all required parameters)
    • Why? This, again, seems confusing to use, and, again, is not allowed in modern programming languages. (C#: A params parameter must be the last parameter in a formal parameter list)
  • Formatting is completely off. See Mindustry's CONTRIBUTING.md.
    • You're adding spaces before braces.
    • SCREAMING_SNAKE_CASE should not be used.
    • Use wildcard imports.

@Zelaux

Zelaux commented Aug 22, 2023

Copy link
Copy Markdown
Author
  1. All these 4 classes can be placed in one CommandHandler, but then it will turn into garbage
  2. Example command /rate [player...] <score> by default player is my self, or other person, or server
    It's like overloding functions
  3. Fixed

@Anuken

Anuken commented Aug 22, 2023

Copy link
Copy Markdown
Owner
  1. Sure, but there's a trivial workaround: just put [player...] at the end. I don't think it's worth massive command handler changes just so a parameter can be reordered.

@Zelaux

Zelaux commented Aug 22, 2023

Copy link
Copy Markdown
Author

It seems to me from the point of view of use it is more logical to write like this
/rate [player...] <score>
it is more logical to first write who I want to rate
But if a want, I can just write a score

Another command
/pay <player...> <coins amount>

@Zelaux

Zelaux commented Aug 22, 2023

Copy link
Copy Markdown
Author

Also I guess my parser and splitter creates less strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants