https://github.com/tina-1300/cppenv
cppenv is a header-only C++ library that makes it easy to manage .env files in your projects.
https://github.com/tina-1300/cppenv
cpp easy env environment-variables fast header-only library package
Last synced: 10 months ago
JSON representation
cppenv is a header-only C++ library that makes it easy to manage .env files in your projects.
- Host: GitHub
- URL: https://github.com/tina-1300/cppenv
- Owner: Tina-1300
- License: mit
- Created: 2025-09-22T18:06:54.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-22T20:15:39.000Z (10 months ago)
- Last Synced: 2025-09-22T22:13:01.209Z (10 months ago)
- Topics: cpp, easy, env, environment-variables, fast, header-only, library, package
- Language: C++
- Homepage:
- Size: 305 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# cppenv
cppenv is a header-only C++ library that makes it easy to manage .env files in your projects.
---
## ✨ Features
- Load `.env` files securely and easily
- Header-only : just include and use
- Simple API for accessing environment variables
- Ideal for config management in C++ projects
---
## 🚀 Quick Start
1. *Install :*
Just copy the cppenv directory into your project - no build step is required.
2. *Use :*
```cpp
#include
#include
int main(){
cppenv::EnvManager envManager;
if (!envManager.load_from_file(".env")){
std::cerr << "Unable to load .env file\n";
}
std::optional db_url = envManager.get_value("DATABASE_URL");
std::optional api_key_telegram = envManager.get_value("TELEGRAM_TOKEN");
std::optional api_key_discord = envManager.get_value("DISCORD_TOKEN");
std::optional api_key_netflix = envManager.get_value("NETFLIX_TOKEN");
std::optional server_port = envManager.get_value_as("SERVER_PORT");
if (!db_url && !api_key_telegram && !api_key_discord && !api_key_netflix && !server_port){
std::cerr << "The environment variables were not found\n";
}
std::cout << "DATABASE_URL : " << *db_url << "\n" << "TELEGRAM_TOKEN : " << *api_key_telegram << "\n";
std::cout << "DISCORD_TOKEN : " << *api_key_discord << "\n" << "NETFLIX_TOKEN : " << *api_key_netflix << "\n" << "SERVER_PORT : " << *server_port << "\n";
return 0;
}
```
3. *screenshot :*
