Skip to content

Add .env loading when the app starts. - #36

Merged
tuxmonteiro merged 1 commit into
mainfrom
feat/env-file-loading
Aug 11, 2026
Merged

Add .env loading when the app starts.#36
tuxmonteiro merged 1 commit into
mainfrom
feat/env-file-loading

Conversation

@tuxmonteiro

Copy link
Copy Markdown
Contributor

Resolves #35

Changes

Add best-effort .env file loading at application startup using the dotenvy crate.

  • New src/env.rs module: load_env() loads .env from the current directory; load_env_from(path) enables testing with temp directories. Missing file = debug log (no error). Present file = info log. Never panics.
  • src/bin/marketdata.rs: calls load_env() immediately after init_logger() and before CLI parsing / config file reading.
  • Cargo.toml: adds dotenvy and tempfile (dev-dependency).
  • .gitignore: adds .env entry (was only .env.local).
  • config.toml: documents .env loading and credential precedence.
  • ADR-012: documents the dotenvy vs config-rs vs manual parsing decision.
  • AGENTS.md: updated project structure to include env module.

Testing

  • 2 new unit tests in src/env.rs (TDD: tests written first, then implementation): verifies a present .env populates env vars and a missing file does not panic.
  • All 64 tests pass. Clippy clean. rustfmt clean.

Precedence

explicit env var > .env file > config.toml — dotenvy only sets vars not already in the environment, and config.toml values take precedence over env vars (ADR-011).

Add a new env module with load_env/ load_env_from that loads
variables from a .env file using dotenvy. Loading is best-effort:
a missing file is logged at debug level and is not treated as an
error. Called in main() after init_logger and before CLI parsing.

- Add dotenvy dependency, create src/env.rs with tests via TDD
- Call load_env() in marketdata.rs after init_logger()
- Add .env to .gitignore, document in config.toml
- Create ADR-012, update AGENTS.md
@tuxmonteiro
tuxmonteiro merged commit 6f085d7 into main Aug 11, 2026
2 checks passed
@tuxmonteiro
tuxmonteiro deleted the feat/env-file-loading branch August 11, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add .env loading when the app starts.

1 participant