https://github.com/nikstar/env
@dynamicMemberLookup interface for environment variables
https://github.com/nikstar/env
env environment swift swift-script
Last synced: 12 months ago
JSON representation
@dynamicMemberLookup interface for environment variables
- Host: GitHub
- URL: https://github.com/nikstar/env
- Owner: nikstar
- License: mit
- Created: 2019-07-07T11:56:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-13T20:17:25.000Z (over 6 years ago)
- Last Synced: 2025-02-05T11:44:48.996Z (about 1 year ago)
- Topics: env, environment, swift, swift-script
- Language: Swift
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Env
`@dynamicMemberLookup` interface for environment variables.
[](#)
[](#)
[](#)
[](https://github.com/nikstar/Env/releases)
[](LICENSE.md)
Add to your project via Swift package manager:
```
.package("https://github.com/nikstar/Env.git", from: "2.0.0")
```
## Example
```swift
guard let home = Env.HOME else { return }
Env.PATH! += ":\(home)/bin"
```
Unsetting varibles:
```swift
Env.LC_LOCALE = nil
```
Throwing access:
```swift
do {
let v = try Env.get("NOTAVAR")
} catch {
print(error) // "environment variable missing: NOTAVAR"
}
```