Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
io.foxcapades.lib:env-access
Advanced tools
Tools and utilities for accessing/mapping environment variables.
= Env Access :toc:
Tools and utilities for accessing a process' environment.
== Usage
This package provides two base environment accessors, Env
and NBEnv
.
Env
reads the environment as is and provides no safeties around empty or blank
environment variables.
NBEnv
treats empty or blank environment variables as if they are missing
entirely.
=== Using Env
The Env
type is useful for cases where the inputs are expected to be able to
be blank, and callers assume the responsibility of checking for empty/blank
values.
==== Optional Lookup
// Env: // FOUND=found // BLANK="" fun main() { val found = Env["FOUND"] assert(found == "found")
val missing = Env["MISSING"] assert(missing == null)
==== Value or Default
// Env: // FOUND=found // BLANK="" fun main() { val found = Env.get("FOUND", "default") assert(found == "found")
val missing = Env.get("MISSING", "default") assert(missing == "default")
==== Map Value
// Env: // FOUND=1234 // BLANK="" fun main() { val found = Env.get("FOUND") { it.toInt() } assert(found == 1234)
val missing = Env.get("MISSING") { it.toInt() } assert(missing == null)
// Throws NumberFormatException as "" is not a valid int value. val blank1 = Env.get("BLANK") { it.toInt() }
==== Map Value or Default
// Env: // FOUND=1234 // BLANK="" fun main() { val found = Env.get("FOUND", 4321) { it.toInt() } assert(found == 1234)
val missing = Env.get("MISSING", 4321) { it.toInt() } assert(missing == 4321)
// Throws NumberFormatException as "" is not a valid int value. val blank1 = Env.get("BLANK", 4321) { it.toInt() }
// -------------------------------------------------------------------------- //
=== Using NBEnv
==== Optional Lookup
// Env: // FOUND=found // BLANK="" fun main() { val found = NBEnv["FOUND"] assert(found == "found")
val missing = NBEnv["MISSING"] assert(missing == null)
==== Value or Default
// Env: // FOUND=found // BLANK="" fun main() { val found = NBEnv.get("FOUND", "default") assert(found == "found")
val missing = NBEnv.get("MISSING", "default") assert(missing == "default")
==== Map Value
// Env: // FOUND=1234 // BLANK="" fun main() { val found = NBEnv.get("FOUND") { it.toInt() } assert(found == 1234)
val missing = NBEnv.get("MISSING") { it.toInt() } assert(missing == null)
==== Map Value or Default
// Env: // FOUND=1234 // BLANK="" fun main() { val found = NBEnv.get("FOUND", 4321) { it.toInt() } assert(found == 1234)
val missing = NBEnv.get("MISSING", 4321) { it.toInt() } assert(missing == 4321)
FAQs
Unknown package
We found that io.foxcapades.lib:env-access demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.