ConfigEnv.dotenv
— Functiondotenv(path1, path2, ...; overwrite = true)
dotenv
reads .env files from your path
, parse their content, merge them together, stores result to ENV
, and finally return a EnvProxyDict
with the content. If no path
argument is given , then .env
is used as a default path. During merge procedure, if duplicate keys encountered then value from the rightmost dictionary is used.
By default if key already exists in ENV
it is overwritten with the values in .env file. This behaviour can be changed by setting overwrite
flag to false
or using dual dotenvx
function.
Examples
# .env
FOO = bar
USER = john_doe
# julia REPL
# load key-value pairs from ".env", `ENV` duplicate keys are overwritten
julia> ENV["USER"]
user1
julia> cfg = dotenv()
julia> ENV["FOO"]
bar
julia> ENV["USER"]
john_doe
julia> cfg["USER"]
john_doe
ConfigEnv.dotenvx
— Methoddotenvx(path1, path2, ...; overwrite = false)
dotenvx
reads .env files from your path
, parse their content, merge them together, stores result to ENV
, and finally return a EnvProxyDict
with the content. If no path
argument is given , then .env
is used as a default path. During merge procedure, if duplicate keys encountered then value from the rightmost dictionary is used.
By default if key already exists in ENV
it is overwritten with the values in .env file. This behaviour can be changed by setting overwrite
flag to true
or using dual dotenv
function.
Examples
# .env
FOO = bar
USER = john_doe
# julia REPL
# load key-value pairs from ".env", `ENV` duplicate keys are not overwritten
julia> ENV["USER"]
user1
julia> cfg = dotenvx()
julia> ENV["FOO"]
bar
julia> ENV["USER"]
user1
julia> cfg["USER"]
john_doe
ConfigEnv.isresolved
— Methodisresolved(cfg::EnvProxyDict)
Returns whether templating procedure was successful or not. Templating can be unsuccessful if there are circular dependencies or templated variables do not exist in the environment.
ConfigEnv.parse
— MethodConfigEnv.parse
accepts a String or an IOBuffer (any value that can be converted into String), and returns a Dict with the parsed keys and values.
ConfigEnv.unresolved_keys
— Methodunresolved_keys(cfg::EnvProxyDict)
Returns tuple of circular
and undefined
keys, where circular
are keys which depends on each other and undefined
are keys, which use variables that do not exist in the environment.