Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamped command parser #121

Merged
merged 3 commits into from
Feb 5, 2022
Merged

Revamped command parser #121

merged 3 commits into from
Feb 5, 2022

Conversation

finnbar
Copy link
Collaborator

@finnbar finnbar commented Jan 28, 2022

This allows subcommands to actually fail properly - previously if a subcommand failed, it would default to the main command. However in cases like

.quote add "blah - author

we would much rather give an error specific to the add command, rather than defaulting to treating this as .quote run with the author add "blah - author.

As such, once we parse the name of a subcommand, there's no going back - the only parser run on the arguments is the one for that subcommand.

Fixes #106, and improves error handling somewhat.

This allows subcommands to actually fail properly
For .sayblah, chunk was correctly consuming "say", but then we got an
unknown error when it tried to consume spaces
@finnbar
Copy link
Collaborator Author

finnbar commented Jan 28, 2022

Also fixes #109 - for .sayblah, chunk was consuming the prefix say and then complaining with an unknown error when it expected spaces instead of blah.

@L0neGamer
Copy link
Collaborator

L0neGamer commented Jan 28, 2022

tested the lengthened command name thing, as well as the subcommand stuff. one thing that seems weird is that when I mangled quote add, the error message didn't pop up, instead I got unknown error. I'll investigate this now.

EDIT:
after a quick investigation, I found the error. Simply replace the left with the right in smart parser and it should be good

to use <?> the original parser must not have consumed any input, which adding try handles.

https://github.com/L0neGamer/tablebot/tree/error-on-subcommand

image

@finnbar finnbar merged commit 20dd1af into main Feb 5, 2022
@finnbar finnbar deleted the error-on-subcommand branch February 5, 2022 14:07
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.

.quote author parsing means that ambiguous errors are produced
2 participants