Skip to content

Commit

Permalink
Fix deprecation for example; Add example link
Browse files Browse the repository at this point in the history
  • Loading branch information
uzzu committed Dec 17, 2023
1 parent 0f89576 commit d6460b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

- [Basic Usage](/examples/basic)
- [Change `.env` filename](/examples/change_file)
- [Change `.env.template` filename](/examples/change_template_file)
- [Hierarchical dotenv definitions](/examples/hierarchical_definitions)
17 changes: 16 additions & 1 deletion examples/basic/sub/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
val keys = listOf(
"FOO",
"BAR",
"BAZ",
"QUX"
)

println("""[$name] ${env.FOO.orElse("default_foo")}""")
println("""[$name] ${env.BAR.orNull()}""")
try {
Expand All @@ -8,4 +15,12 @@ try {
println("""[$name] ${env.QUX.value}""")

// All environment variables which are merged with variables specified in .env files.
env.allVariables
print("[$name] #allVariables() (filtered by keys in .env.template and .env): ")
println(env.allVariables().filterKeys { keys.contains(it) })

// All environment variables which are merged with variables specified in .env files includes null.
// The Plugin set key if defined in .env template files, but it could not be retrieved as nullable value entries by using allVariables()
// By using allVariablesOrNull instead of allVariables, it is possible to retrieve all environment variables, including those that are only defined in the .env template (which means their values are null).
env.allVariablesOrNull()
print("[$name] #allVariablesOrNull() (filtered by keys in .env.template and .env): ")
println(env.allVariablesOrNull().filterKeys { keys.contains(it) })

0 comments on commit d6460b7

Please sign in to comment.