Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.16 new API #123

Merged
merged 39 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a45eeda
Use 2024 edition, mark unsafe
allan2 Aug 29, 2024
fa19b77
New API
allan2 Sep 2, 2024
5012a99
Rename `from_path` to `with_path`
allan2 Sep 5, 2024
0f9ad5f
New `Error` type with `NotPresent(String)`
allan2 Sep 5, 2024
b585c41
Add `dotenvy::var` with new error type
allan2 Sep 5, 2024
13231f6
Make a `EnvMap` a newtype with `EnvMap::var`
allan2 Sep 5, 2024
2fac955
Add version display for CLI
allan2 Sep 6, 2024
6334ceb
Add required and override to CLI
allan2 Sep 6, 2024
9ad1045
Add variable name to Unicode error
allan2 Sep 6, 2024
c4263c8
Fix error usage
allan2 Sep 6, 2024
81dd772
cargo fmt
allan2 Sep 6, 2024
cb5be8d
Add file path to IO error variant
allan2 Sep 8, 2024
312fac6
Fix lowercase error message test
allan2 Sep 8, 2024
9b3e9ad
Add `path` setter for reader error context
allan2 Sep 8, 2024
d7d0128
Test BOM removal at lower level
allan2 Sep 8, 2024
c788494
Remove IO from load substitution test
allan2 Sep 8, 2024
fe46d1d
Remove default location tests
allan2 Sep 8, 2024
b426cbf
Remove panics from parse unit tests
allan2 Sep 8, 2024
3b05ea8
Remove deprecated test
allan2 Sep 8, 2024
ec0b6a3
Use safe API in mutiline tests
allan2 Sep 8, 2024
d07c421
Remove unused test dir
allan2 Sep 8, 2024
f72df37
Load env for substitution test
allan2 Sep 8, 2024
aa2a0e1
Remove unmeaningful `dotenvy::Error` tests
allan2 Sep 8, 2024
20847a4
Minor signature syntax
allan2 Sep 8, 2024
befc817
Add `load` tests, use temp-env
allan2 Sep 8, 2024
faeba1b
Revert edition to 2021
allan2 Sep 8, 2024
92158d9
Update MSRV to 1.74.0
allan2 Sep 8, 2024
5b4313a
Remove unnecessary `extern`
allan2 Sep 8, 2024
23aade4
Conditional Unix `use`
allan2 Sep 8, 2024
f4dec21
Remove die macro
allan2 Sep 8, 2024
6822a04
More useful comment for CLI file arg
allan2 Sep 8, 2024
9663c8a
Attempt to fix Windows build
allan2 Sep 8, 2024
43a167e
Fix env file spelling
allan2 Sep 9, 2024
ab5b754
Use root README for dotenvy crate
allan2 Sep 9, 2024
a8ff414
Upgrade syn 1 to syn 2
allan2 Sep 9, 2024
9b3db89
Fix default path
allan2 Sep 9, 2024
deb2b49
clippy needless_raw_string_hashes
allan2 Sep 9, 2024
169a60e
Inline fmt args, default error message
allan2 Sep 9, 2024
c2070b0
Fix default construction path
allan2 Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
Cargo.lock
.vscode/
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed
- update to 2021 edition
- update MSRV to 1.72.0
- **breaking**: dotenvy CLI uses `from_path` instead of `from_filename`
- update MSRV to 1.74.0

- **breaking**: `dotenvy::Error` now includes IO file path info and variable name info
- **breaking**: `dotenvy::var` no longer calls `load` internally
- **breaking**: `dotenvy::Result` is now private
- **breaking**: deprecate `dotenvy::var`, `dotenvy::from_filename*`
- `Error` is now `From<std::io::Error`

- **breaking**: dotenvy CLI uses `with_path` instead of `from_filename`
- **breaking**: dotenvy CLI defaults to *./.env*, no longer traversing parent directories.
- **breaking**: dotenvy CLI exits with code 2 instead of code 1 if the external command is omitted
- Fix doctests on windows not compiling ([PR #79](https://github.com/allan2/dotenvy/pull/79) by [vallentin](https://github.com/vallentin).
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["dotenv", "dotenv_codegen"]
members = ["dotenvy", "dotenvy-macros", "dotenv_codegen", "examples/*"]
resolver = "2"
1 change: 0 additions & 1 deletion README.md

This file was deleted.

79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# dotenvy

[![Crates.io](https://img.shields.io/crates/v/dotenvy.svg)](https://crates.io/crates/dotenvy)
[![msrv
1.74.0](https://img.shields.io/badge/msrv-1.74.0-dea584.svg?logo=rust)](https://github.com/rust-lang/rust/releases/tag/1.74.0)
[![ci](https://github.com/allan2/dotenvy/actions/workflows/ci.yml/badge.svg)](https://github.com/allan2/dotenvy/actions/workflows/ci.yml)
[![docs](https://img.shields.io/docsrs/dotenvy?logo=docs.rs)](https://docs.rs/dotenvy/)

A well-maintained fork of the [dotenv](https://github.com/dotenv-rs/dotenv) crate.

This crate is the suggested alternative for `dotenv` in security advisory [RUSTSEC-2021-0141](https://rustsec.org/advisories/RUSTSEC-2021-0141.html).

This library loads environment variables from a _.env_ file. This is convenient for dev environments.

## Components

1. [`dotenvy`](https://crates.io/crates/dotenvy) crate - A well-maintained fork of the `dotenv` crate.
2. [`dotenvy_macro`](https://crates.io/crates/dotenvy_macro) crate - A macro for compile time dotenv inspection. This is a fork of `dotenv_codegen`.
3. `dotenvy` CLI tool for running a command using the environment from a _.env_ file (currently Unix only)

## Usage

##

```rs
use dotenvy::EnvLoader;
use std::env;

fn main() {
let env_map = EnvLoader::with_path(".env").load()?;
for (key, value) in env_map {
println!("{key}: {value}");
}
}
```

### Loading at compile time

The `dotenv!` macro provided by `dotenvy_macro` crate can be used.

## Minimum supported Rust version

We aim to support the latest 8 rustc versions - approximately 1 year. Increasing
MSRV is _not_ considered a semver-breaking change.

## Why does this fork exist?

The original dotenv crate has not been updated since June 26, 2020. Attempts to reach the authors and present maintainer were not successful ([dotenv-rs/dotenv #74](https://github.com/dotenv-rs/dotenv/issues/74)).

This fork intends to serve as the development home for the dotenv implementation in Rust.

## What are the differences from the original?

This repo fixes:

- home directory works correctly (no longer using the deprecated `std::env::home_dir`)
- more helpful errors for `dotenv!` ([dotenv-rs/dotenv #57](https://github.com/dotenv-rs/dotenv/pull/57))

It also adds:

- multiline support for environment variable values
- `io::Read` support via [`from_read`](https://docs.rs/dotenvy/latest/dotenvy/fn.from_read.html) and [`from_read_iter`](https://docs.rs/dotenvy/latest/dotenvy/fn.from_read_iter.html)
- improved docs

For a full list of changes, refer to the [changelog](./CHANGELOG.md).

## Contributing

Thank you very much for considering to contribute to this project! See
[CONTRIBUTING.md](./CONTRIBUTING.md) for details.

**Note**: Before you take the time to open a pull request, please open an issue first.

## The legend

Legend has it that the Lost Maintainer will return, merging changes from `dotenvy` into `dotenv` with such thrust that all `Cargo.toml`s will lose one keystroke. Only then shall the Rust dotenv crateverse be united in true harmony.

Until then, this repo dutifully carries on the dotenv torch. It is actively maintained.
```
1 change: 0 additions & 1 deletion dotenv/LICENSE

This file was deleted.

82 changes: 0 additions & 82 deletions dotenv/README.md

This file was deleted.

76 changes: 0 additions & 76 deletions dotenv/src/bin/dotenvy.rs

This file was deleted.

117 changes: 0 additions & 117 deletions dotenv/src/errors.rs

This file was deleted.

Loading
Loading