Skip to content
/ Env Public

@dynamicMemberLookup interface for environment variables

License

Notifications You must be signed in to change notification settings

nikstar/Env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Env

@dynamicMemberLookup interface for environment variables.

Swift 5 Platforms: macOS, Linux Swift Package Manager compatible releases MIT license

Add to your project via Swift package manager:

        .package("https://github.com/nikstar/Env.git", from: "2.0.0")

Example

guard let home = Env.HOME else { return }
Env.PATH! += ":\(home)/bin"

Unsetting varibles:

Env.LC_LOCALE = nil

Throwing access:

do {
    let v = try Env.get("NOTAVAR")
} catch {
    print(error) // "environment variable missing: NOTAVAR"
}