H-uru / Plasma

Cyan Worlds's Plasma game engine
http://h-uru.github.io/Plasma/
GNU General Public License v3.0
203 stars 80 forks source link

Refactor and add tests for console command parsing #1459

Closed dgelessus closed 11 months ago

dgelessus commented 1 year ago

Converts the very "old C-like" console command parsing code into its own class that has a bit more structure and uses modern C++ data types. Also, unit tests!

Aside from cleaning up the code, my motivation here is to allow parsing console commands without actually executing them. This would be especially useful for parsing .ini files - thinking of server.ini or cases like in #1244.

Suggestions for improving the parsing API are welcome. It has to be a bit complex unfortunately, to support situations where the input should only be partially parsed (e. g. tab completion), and because of the wacky command name syntax where parsing depends on which commands are defined...

dpogue commented 11 months ago

There's one (fairly trivial) conflict here, but this seems good to me from a quick skim over things

dgelessus commented 11 months ago

(I'll get the rebase done this weekend probably)