levibostian / dotenv-android

Access environment variables from .env file within Android app
MIT License
16 stars 2 forks source link

Support null/empty values #22

Closed slhck closed 3 years ago

slhck commented 3 years ago

This is a feature request.

When I add empty env variables like:

ELASTICSEARCH_TEST_URL=

Or:

ELASTICSEARCH_TEST_URL=""

These are not resolved, and therefore not available in the program code.

Feature: Make empty variables available in Env, but simply set to an empty string (in case of ""), or null (in case of no value) so that you can programmatically deal with them and determine absence of the values.

Otherwise I have no easy way to provide optional values.

Consider the case where this .env file is necessary for a certain functionality only, so the values don't have to be set at all times. I cannot just remove them completely, as the code wouldn't compile anymore. I also cannot set them to bogus values like foo, because I would have to provide extra check like if Env.elasticsearchTestUrl == "foo" instead of a semantically more correct if Env.elasticsearchTestUrl == null, or add a check for .length() == 0.

slhck commented 3 years ago

Oh, I realize this should be added to https://github.com/levibostian/dotenv/ and not here. Moving there.

levibostian commented 3 years ago

The work to support this feature has been completed on the CLI end. Now, all that needs to happen is update the CLI version in the plugin and this will ship!

levibostian commented 3 years ago

Deployed with v1.3.0

https://github.com/levibostian/dotenv-android/releases/tag/1.3.0

slhck commented 3 years ago

This works perfectly now for my use case. Thank you!