Swiftpack.co - Package - markmals/Envy

Envy

Envy is an enviroment variable manager, based off of SwiftDotEnv. It uses @dynamicMemberLookup, subscripts, and generic functions to retrieve information, type-checked, from your .env file on the server.

All the tests are passing and this is currently a production-ready library. Feel free to submit issues or pull-requests for cases in which you find it not to work.

Installation

I recommend you use Swift Package Manager to use Envy in your server-side project. Add this line to your Package.swift, as an element in your package's dependencies, run swift package fetch (or any superset of that command), and you should be all set:

.package(url: "https://github.com/markmals/Envy", from: "1.0.0"),

Usage

If this is your .env file:

DB_HOST=test.com
DB_PORT=1234
IS_ENABLED=0

Then this code will extract its variables for use in Swift:

import Envy

let env = Envy(with: ".env")

let host: String = env.DB_HOST ?? "localhost"
let port: Int = env.DB_PORT ?? 3306
let isEnabled: Bool = env.IS_ENABLED ?? true

See the tests for more usage examples.

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total:

Releases

1.0.0 - Nov 24, 2018

Tests are fully passing and everything works as expected. Feel free to use in production code.