https://github.com/luckyframework/lucky_env
An environment variable manager
https://github.com/luckyframework/lucky_env
Last synced: 4 months ago
JSON representation
An environment variable manager
- Host: GitHub
- URL: https://github.com/luckyframework/lucky_env
- Owner: luckyframework
- License: mit
- Created: 2021-02-13T23:51:04.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-06-01T16:25:53.000Z (about 1 year ago)
- Last Synced: 2025-06-02T01:04:55.392Z (about 1 year ago)
- Language: Crystal
- Homepage:
- Size: 91.8 KB
- Stars: 5
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LuckyEnv
Yet another environment variable manager. Read from a file like a `.env`
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
lucky_env:
github: luckyframework/lucky_env
```
2. Run `shards install`
## Usage
### Environment variable file
Create your "env" file. Name it whatever you want. Most common is `.env`.
The file is created with key/value pairs separated by `=`.
```text
APP_NAME=my_app
LUCKY_ENV=development
DEV_PORT=3002
DB_NAME=${APP_NAME}_${LUCKY_ENV}
```
### Crystal code
```crystal
# This would normally go in your `src/shards.cr` file
require "lucky_env"
# Loads the ".env" file. Raises if it is missing
LuckyEnv.load(".env")
# Use `load?` if the file is optional.
# This will not raise if the file is missing
LuckyEnv.load?(".env")
ENV["LUCKY_ENV"] == "development" # => true
# Returns whatever `ENV["LUCKY_ENV"]` is set to, or `"development"` if not set.
LuckyEnv.environment # => "development"
# Environment predicates
LuckyEnv.development? # => true
LuckyEnv.production? # => false
LuckyEnv.test? # => false
```
## Development
Install shards `shards install`, and start making changes.
Be sure to run `./bin/ameba`, and the crystal formatter `crystal tool format spec src`.
Read through the issues for things you can work on. If you have an idea, feel free to
open a new issue!
## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [Jeremy Woertink](https://github.com/jwoertink) - creator and maintainer