https://github.com/ehsanmok/envo
Typed config loading from env vars, TOML, and CLI for Mojo🔥
https://github.com/ehsanmok/envo
Last synced: 2 months ago
JSON representation
Typed config loading from env vars, TOML, and CLI for Mojo🔥
- Host: GitHub
- URL: https://github.com/ehsanmok/envo
- Owner: ehsanmok
- License: mit
- Created: 2026-04-08T19:48:01.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-08T20:11:09.000Z (3 months ago)
- Last Synced: 2026-04-10T10:40:09.927Z (3 months ago)
- Language: Mojo
- Homepage: https://ehsanmok.github.io/envo/
- Size: 16.6 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# envo
[](https://github.com/ehsanmok/envo/actions)
[](https://ehsanmok.github.io/envo)
[](LICENSE)
Typed config loading from env vars, TOML, and CLI for Mojo.
`envo` composes [`morph`](https://github.com/ehsanmok/morph)'s TOML and
CLI parsing with a single libc `getenv(3)` FFI call to give you layered,
typed configuration with zero boilerplate.
## Precedence
```
CLI args --port 9090 (highest)
env vars PORT=9090
TOML file port = 8080 (lowest)
```
## Quick start
```mojo
from envo import load_config
@fieldwise_init
struct ServerConfig(Defaultable, Movable):
var host: String
var port: Int
var debug: Bool
def __init__(out self):
self.host = "localhost"
self.port = 8080
self.debug = False
var cfg = load_config[ServerConfig]("config.toml")
# PORT=9090 in environment -> cfg.port == 9090
# --debug on CLI -> cfg.debug == True
```
With explicit CLI args:
```mojo
var cfg = load_config[ServerConfig]("config.toml", args=argv())
```
Low-level env var access:
```mojo
from envo import getenv, getenv_or
var home = getenv("HOME") # Optional[String]
var port = getenv_or("PORT", "8080") # String
```
## Field name mapping
| Struct field | Env var | CLI flag |
|------------- |----------- |-------------- |
| `host` | `HOST` | `--host` |
| `db_url` | `DB_URL` | `--db-url` |
| `max_conns` | `MAX_CONNS`| `--max-conns` |
## Supported field types
`String`, `Int`, `Int64`, `Bool`, `Float64`, `Float32`,
`Optional[String]`, `Optional[Int]`, `Optional[Float64]`, `Optional[Bool]`,
`List[String]`, `List[Int]`
## Installation
```toml
# pixi.toml
[dependencies]
envo = { git = "https://github.com/ehsanmok/envo.git", branch = "main" }
```
## Development
```bash
pixi run tests # run all tests
pixi run example # run example
pixi run bench # run benchmarks
pixi run -e dev docs # build and open docs
```
## License
[MIT](LICENSE)