Repository navigation
Conversation
fix: get_env error return for unset variables.
| conf: List(#(String, String)), | ||
| conf_example: List(#(String, String)), |
There was a problem hiding this comment.
Slight nit but I try to refrain from the shorter forms like conf, config is preferrable.
| DotEnv(path: String, debug: Bool, capitalize: Bool, ignore_missing_file: Bool) | ||
| DotEnv( | ||
| path: String, | ||
| check_example: Bool, |
There was a problem hiding this comment.
Can we make this validate_template or similar instead? 🤔
There was a problem hiding this comment.
To keep it simple, my current implementation always looks for {path}.example, so check_example made that behavior explicit.
I'm in favor of validate_template, but I think it should come with a template_path option.
|
Hi @aosasona |
Thank you! I will take a look during the week, it’s been quite busy here today |
|
Thanks a lot @yanshuy, great work! Had some time to take a further look and I have some thoughts on what we could do better here, on both ends, and we could much more simplify this I think; I am realizing, we already have all the tools we need, and perhaps a new way to do options and some other things. I will hack together a prototype this evening and tag you on that, if you want to proceed with the PR, happy to, if not, I can complete it based on that and your existing work while rightfully crediting you. My thoughts around options is to do this instead: type Options {
ValidateTemplates(path: List(String))
Capitalize
Debug
IgnoreMissingFiles
}so that This should make options more composable, and should ideally remove the need to have more and more fields in the |
That would be a great improvement. I'd like to see what you come up with. |
…s, and revert to original tests
0a9551b to
42ed098
Compare
Related: #9
This PR introduces a
validate_templateconfiguration option that warns users if environment variables defined in their template file (defaulting to.env.example) are missing from the loaded environment or OS variables.Changes included:
validate_templateoption toOpts(defaults toTrueto match the issue's requirements).template_pathoption to allow users to override the default{path}.examplevalidation file.src/dot_env/internal/template.gleamfor missing key validation.Bug Fix: Fixed an issue in
src/dot_env_ffi.mjswhereget_envfor missing keys was incorrectly returning an emptyGleamError(Nil)instead of a proper error string (GleamError("key <key> is not set")).