Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Paul1365972
Copy link
Contributor

@Paul1365972 Paul1365972 commented Oct 17, 2025

This PR refactors all command related stuff into a new cohesive unified and declarative command system.
Commands are defined using a builder pattern with and a tree structure of CommandNodes.
This provides centralized command registration, better safer argument parsing, autocomplete generation, usage hints and nice error messages.

All command related stuff have been reorganized into core/src/commands/ and generic worldedit stuff into core/src/worldedit/.
The commands are defined in core/src/commands/builtin/.
The "normal" and worldedit commands are not longer split and are now equal citizens.
I also cleaned up some code around core/src/plot/mod.rs

New Features

  • New /help [<command>] command
  • New error messages and nice usage hints when user inputs a wrong command
  • Fixed bugs in some worldedit commands (not sure which anymore EDIT: I rediscovered at least the important one I fixed, there was a missing - 1 for x, y and z in worldedit::execute::execute_paste)
  • Custom command aliases with placeholder support let users define shortcuts like /rpd → /rp compile -iou {} where {} is replaced with arguments. Defined in Config.toml and integrates nicely with autocomplete in most part.
  • Flag arguments are now better supported with both short (-f) and long (--flag) forms and associated help

For now I have marked this as a draft, as I did not have the time to confirm all commands work without any regressions.
The error messages could also still be improved for certain cases. Same goes for some commands while we are at it.

Btw this PR is mutually exclusive with basically every other currently open PRs, so we should probably address them first (And I will have the enjoyment of fixing the endless amounts of merge conflicts that will result from that-).

@Paul1365972
Copy link
Contributor Author

Paul1365972 commented Oct 17, 2025

I would have also liked to remove CompilerOptions::parse as it is unused right now, but I know some of our modifications depend on it, so I left it for now. Open to feedback.

There was also an attempt at creating a macro based DSL, but that failed miserably as rusts nice compiler errors turn not so nice very quickly when using macros. Although you could still add a DSL on top of the new CommandNode-based API right now.

It may also make sense to extract the core command infrastructure (so everything except the command definitions) into its own crate, although I am not sure if this would be a good idea. The worldedit stuff could possibly also be extracted, but again, not sure if this makes sense.

@Paul1365972
Copy link
Contributor Author

Here a small preview of what the new system looks like (all automagically derived from the definition):

image

@StackDoubleFlow
Copy link
Member

Thanks for taking on this mammoth of a task

@Paul1365972 Paul1365972 marked this pull request as ready for review October 24, 2025 02:03
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