{"id":28165739,"url":"https://github.com/siguici/envig","last_synced_at":"2026-01-31T13:01:54.290Z","repository":{"id":283062398,"uuid":"950547366","full_name":"siguici/envig","owner":"siguici","description":"A lightweight and flexible environment variable manager for V, inspired by dotenv and dotenv-expand. 🛠️","archived":false,"fork":false,"pushed_at":"2025-03-18T11:12:41.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T11:40:01.554Z","etag":null,"topics":["config","config-manager","dotenv","env","envigure","siguici","vlang","vpm"],"latest_commit_sha":null,"homepage":"https://vpm.vlang.io/packages/siguici.envig","language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siguici.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-18T10:31:13.000Z","updated_at":"2025-03-18T11:12:45.000Z","dependencies_parsed_at":"2025-03-18T11:40:06.443Z","dependency_job_id":"7e250b10-8241-430b-8087-4db20cd1923b","html_url":"https://github.com/siguici/envig","commit_stats":null,"previous_names":["siguici/envigure"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siguici%2Fenvig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siguici%2Fenvig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siguici%2Fenvig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siguici%2Fenvig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siguici","download_url":"https://codeload.github.com/siguici/envig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337508,"owners_count":22054255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","config-manager","dotenv","env","envigure","siguici","vlang","vpm"],"created_at":"2025-05-15T12:12:06.868Z","updated_at":"2026-01-31T13:01:54.285Z","avatar_url":"https://github.com/siguici.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌟 Envig – Unified Configuration and Environment Manager for V\n\n[![Envig](https://img.shields.io/badge/V-Module-blue.svg)](https://vpm.vlang.io/packages/siguici.envig)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/siguici/envig/blob/HEAD/LICENSE.md)\n[![CI](https://github.com/siguici/envig/workflows/CI/badge.svg)](https://github.com/siguici/envig/actions)\n\n**Envig** is a lightweight and flexible configuration\nand environment manager for **V**.  \nIt unifies configuration loading from TOML files and environment variables,\nand supports dynamic expansion like `dotenv-expand`.\n\n---\n\n## 🚀 Features\n\n✅ Load configuration from TOML files dynamically  \n✅ Support for environment variables via `.env` files  \n✅ Dynamic variable expansion (`${VAR_NAME}` style)  \n✅ Load from directories, single files, or raw text  \n✅ Fallback and default values for missing keys  \n✅ Type-safe retrieval with automatic conversion  \n✅ Lightweight and fast, designed specifically for the V language  \n\n---\n\n## 📦 Installation\n\nInstall it via VPM:\n\n```sh\nv install siguici.envig\n````\n\nOr add it to your dependencies:\n\n```v\nimport siguici.envig\n```\n\n---\n\n## ⚙️ Usage\n\n### 🔹 Loading Configuration\n\n#### Use default options\n\n```v\nimport siguici.envig\n\nmut config := envig.new()\nprintln(config.string('database.host'))\n```\n\n#### Specify the config file and/or directory\n\n```v\nimport siguici.envig\n\nmut config := envig.new(\n  file: 'config.toml'\n  dir: 'config'\n)\nprintln(config.string('database.host'))\n```\n\n#### From a Single File\n\n```v\nimport siguici.envig\n\nmut config := envig.new(file: 'config.toml')\nprintln(config.string('database.host'))\n```\n\n#### From a Directory\n\n```v\nmut config := envig.new(dir: 'config')\nprintln(config.bool('app.debug'))\n```\n\n#### From Raw TOML Text\n\n```v\ntoml_text := \"\"\"\n[database]\nhost = \"localhost\"\nport = 5432\n\"\"\"\nmut config := envig.new(raw: toml_text)\nprintln(config.int('database.port')) // 5432\n```\n\n---\n\n### 🔹 Handling Environment Variables\n\n#### Loading `.env` Files\n\n```v\nimport siguici.envig\n\nmut config := envig.new(env: 'local')\nprintln(config.env('APP_NAME'))\n```\n\n#### Expanding Variables Dynamically\n\n```v\n# .env\nAPP_ENV=production\nDB_URL=\"postgres://user:password@localhost:5432/${APP_ENV}\"\n```\n\n```v\nmut config := envig.new(env: 'production')\nprintln(config.env('DB_URL')) // \"postgres://user:password@localhost:5432/production\"\n```\n\n---\n\n### 🔹 Unified Interface: The `Envig` Manager\n\nEnvig provides a powerful unified interface combining environment and configuration:\n\n```v\nmut e := envig.new()\n\nport := e.env_or_default('PORT', '8080')\ndb_url := e.get('database.url')\ndebug := e.get_as[bool]('app.debug')\n\nprintln('Server running on port $port')\nprintln('Database URL: $db_url')\nprintln('Debug mode: $debug')\n```\n\nOr specify custom options:\n\n```v\nmut e := envig.new(envig.EnvigOptions{\n    dir: 'settings',\n    file: 'app.toml',\n    env: 'production',\n})\n```\n\n---\n\n## 💡 Examples of Unified Access\n\n| Purpose                           | Example                                                     |\n| --------------------------------- | ----------------------------------------------------------- |\n| Get environment variable          | `val := e.env('PORT')`                                      |\n| Get environment with default      | `val := e.env_or_default('PORT', '3000')`                   |\n| Get config value (toml.Any)       | `cfg := e.config('database.url')`                           |\n| Config with default fallback      | `cfg := e.config_or_default('db', 'localhost')`             |\n| Expand variables in a string      | `expanded := e.expand('${DATABASE_URL}')`                   |\n| Unified get (config + expansion)  | `val := e.get('database.url')`                              |\n| Unified get with default fallback | `val := e.get_or_default('service.url', 'https://default')` |\n| Get as a specific type            | `debug := e.get_as[bool]('app.debug')`                      |\n\n---\n\n## 📚 API Reference\n\n### Config \u0026 ConfigManager (Configuration Handling)\n\n| Method                                                         | Description                                                        |\n| -------------------------------------------------------------- | ------------------------------------------------------------------ |\n| Config.new(raw string)                                       | Creates a config from raw text or TOML file (panics on error).     |\n| Config.new_opt(raw string) !Config                           | Optional version returning error instead of panic.                 |\n| ConfigManager.new(opts ConfigOptions)                        | Creates a config manager with options (dir, file).             |\n| ConfigManager.load(opts ConfigOptions)                       | Loads configuration from file, directory or raw text.              |\n| ConfigManager.load_dir(path string)                          | Loads all TOML files in a directory.                               |\n| ConfigManager.load_file(path string)                         | Loads a single TOML file.                                          |\n| ConfigManager.load_text(text string)                         | Loads config from raw TOML text.                                   |\n| ConfigManager.value(path string)                             | Retrieves a value by key (supports nested keys like config.key). |\n| ConfigManager.value_or_default(key string, default toml.Any) | Retrieves a value or returns a default.                            |\n\n### Env \u0026 Dotenv (Environment Variable Handling)\n\n| Method                                 | Description                                               |\n| -------------------------------------- | --------------------------------------------------------- |\n| Env.new(options EnvOptions)          | Creates an environment with a map of variables.           |\n| Env.set(key, value)                  | Sets an environment variable.                             |\n| Env.get(key)                         | Retrieves a variable (returns empty if missing).          |\n| Env.get_or_default(key, default)     | Retrieves a variable or returns default.                  |\n| Env.apply()                          | Applies all variables to the OS environment.              |\n| Dotenv.load(options DotenvOptions)   | Loads a .env file (appends .APP_ENV if defined).      |\n| Dotenv.load_multiple(files []string) | Loads multiple .env files.                              |\n| Dotenv.expand()                      | Expands variables inside other variables (e.g. ${VAR}). |\n\n---\n\n### **Envig** (Unified Manager)\n\n| Method                             | Description                                          |\n| ---------------------------------- | ---------------------------------------------------- |\n| `new(options EnvigOptions)`      | Initialize a new Envig instance                      |\n| `config(path string)`              | Get a configuration value (`toml.Any`)               |\n| `env(name string)`                 | Get an environment variable                          |\n| `get(key string)`                  | Get config with expansion                            |\n| `value(key string)`                | Get as `toml.Any`                                    |\n| `get_as[T](key string)`            | Type-safe retrieval (`T` can be `int`, `bool`, etc.) |\n| `config_or_default(path, default)` | Config value or fallback                             |\n| `env_or_default(name, default)`    | Env variable or fallback                             |\n| `expand(value toml.Any)`           | Expand variable references                           |\n| `get_or_default(key, default)`     | Unified get with default                             |\n\n---\n\n## 🏗️ Roadmap\n\n* [ ] Support for JSON and YAML configuration formats\n* [ ] CLI tool for managing environment variables\n* [ ] Integration with logging and debugging tools\n\n---\n\n## 🤝 Contributing\n\nFeel free to submit issues, ideas, or pull requests!\nLet’s build something great together.\n\n---\n\n## 📜 License\n\nEnvig is released under the **MIT License**.\n\n---\n\n## ⭐ Show Your Support\n\nIf you like **Envig**, give it a *⭐* on [GitHub](https://github.com/siguici/envig)!\n\n---\n\nEnjoy seamless configuration management with **Envig**! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiguici%2Fenvig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiguici%2Fenvig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiguici%2Fenvig/lists"}