-
Notifications
You must be signed in to change notification settings - Fork 503
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 support for environment variable interopolation #264
Comments
I would feel comfortable taking this endeavor on, just wondering if you think the proposed implementation would be acceptable. |
This also seems to be related to #245 where environment variables are being resolved as well, not sure if you want to merge the two and find a way to solve both. |
I think there are a few solutions here:
This is ergonomic and similar to shell syntax, but NAME tokens are limited, they can't start with numbers (in case that just is extended in the future to support integer literals), so it won't work in all cases.
This is less ergonomic and less similar to shell syntax, and so will probably be quite surprising to users.
This is probably the most work, but feels like the best solution to me. Once function-call syntax is allowed, all sorts of useful built-in functions can be added without needing to modify the parser. Also, function-call notation permits multiple arguments more naturally than The grammar would be amended like so:
This is a lot more work than the |
Just some thoughts:
|
The function route is definitely a bit more work, but Also, if And, finally, I've been kind of expecting that I'd need to add function call syntax eventually, so the extra complexity isn't too a big deal :P |
This sounds like #245 a lot, which I think would be a nice feature anyway. But I don't think instantly failing is a terrible idea, sometimes if you're in a new environment it's nice to know when you don't have something populated (PORT, target_dir, etc), in a certain light this might be a feature. Or, maybe only have it fail if the recipe will actually reference the value. Because sometimes defaults can get kind of weird, like what OS they are using. Also, the get-with-default would be useful in a recipe, but still awkward with variables until the ability to then reference the value in another variable becomes available:
You could also just do this in the recipe, but in a few cases it feels more ergonomic to construct common settings in the just prelude. |
Put up #277 which adds simple functions that don't take any arguments. Next step is functions that actually take arguments. I'll probably add:
Not really wedded to the names, and undecided on whether to allow functions to take a variable number of arguments or not. These would solve the use-case in #245 like so:
|
You can now use |
If you do want to add a variable that derives from an environment variable, you have do something like:
feels like it would be more ergonomic to allow for it to resolve the env var itself:
Seems like the grammar should be able to support this in a non-breaking way:
And then when evaluating the ENV_VAR we just take the "name" portion of it and pass it to std::env::var which should be a platform agnostic way to get that value.
The text was updated successfully, but these errors were encountered: