Roguelike-Celebration / azure-mud

MIT License
185 stars 29 forks source link

SlashCommand: tell the user when a parameter is missing #835

Closed dijkstracula closed 1 month ago

dijkstracula commented 10 months ago

Hello!

This is my attempt at addressing the main issue that I filed https://github.com/Roguelike-Celebration/azure-mud/issues/829 . This patch does not touch any of the subsequent comments in that issue (I do not warn if an extraneous argument is passed to a single-parameter command or attempt to deal with malformed slash commands like simply typing /; nor do I touch anything on the backend). matchingSlashCommand now returns, morally, a union: either a successful SlashCommand object or one of two failure strings, which the caller matches on. This allowed the caller's logic to be simplified a bit, which is nice.

I am not a typescript person (or, really, a frontend person at all) so I hope this is an idiomatic solution. here is a REPL with some tests.

I was hoping that I'd be able to attach a local frontend to the running backend during this week's Celebration, but it looks like from the README that I still require an API key and a FireBase thingie to do so? If there's a trivial way of pointing it to prod then I'm happy to test it that way, of course.