Replace avram parsing with ParamParser #1616
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Fixes #1383
Description
Where we were relying on Avram's parsing, this adds a new
Lucky::ParamParser
that handles it a bit differently than Avram does. Instead of adding methods to the types, there's one module with methods (with the same name) for the various types. Logically, though, it works the same. This new way is a bit nicer in that everything for parsing is in one place and not spread out in multiple files.I did not include parsing for Enums and JSON. Unfortunately it is not possible to have a method generic for all enums and I didn't think JSON was necessary though I think it would be easy enough to add.
I have a potential solution for the enum thing though. What if
param
could be provided a block that gets the string value and it returns the parsed value matching their variable or nil if it couldn't be parsed?Just a thought if we feel like it's absolutely necessary to support that.
Checklist
crystal tool format spec src
./script/setup
./script/test