-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add mix task (or Ash Injector?) to replace ~CURL with %Req.Request{} #23
Comments
That sounds like an awesome idea!
Maybe the mix task |
Sourceror is the other lib that can help us here (it's what igniter uses under the hood) |
True! I did a quick test and it could work! Heres my Livebook Test Curl Sigil ExpansionMix.install([
{:sourceror, "~> 1.7"},
{:curl_req, "~> 0.98.6"},
]) Sourcerorimport CurlReq
"""
~CURL(https://example.com)
"""
|> Sourceror.parse_string!()
|> Macro.postwalk(fn
{:sigil_CURL, _dot_meta, _rest} = quoted ->
Macro.expand_once(quoted, __ENV__)
quoted ->
quoted
end)
|> Sourceror.to_string()
|> Code.eval_string()
|> elem(0)
|
It looks like you're already 90% of the way there! |
It would be nice to have a mix task or injector that you can call that replaces all instances of the
~CURL
sigil in your code with the corresponding%Req.Request{}
. That would enable workflows like: coding with~CURL
and when you're done, run the mix task to convert it all to%Req.Request{}
, which is, I think, what most (or at least many) people want in their app at the end of the day.The text was updated successfully, but these errors were encountered: