Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sryze/dotenv

Load .env files in C++
https://github.com/sryze/dotenv

cplusplus dotenv library

Last synced: about 1 month ago
JSON representation

Load .env files in C++

Awesome Lists containing this project

README

        

dotenv
======

[![Build Status][build_status]][build]

Example code:

```c++
#include
#include "dotenv.h"

int main() {
dotenv::load();

auto foo = dotenv::get("FOO");
std::cout << "FOO = " << foo << std::endl;

// It also works with getenv() from the standard library:
auto bar = getenv("BAR");
if (bar != nullptr) {
std::cout << "BAR = " << bar << std::endl;
}
}
```

In your .env file:

```sh
FOO=hello
BAR=world
```

There is also a command-line tool that can run any program with a user-provided
env-file, e.g.:

```
./dotenv /path/to/.env -- sh -c 'echo $FOO'
```

[build]: https://travis-ci.org/sryze/dotenv
[build_status]: https://travis-ci.org/sryze/dotenv.svg?branch=master