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

Add Dotenv.parse method #362

Merged
merged 3 commits into from
Feb 21, 2019
Merged

Conversation

rossta
Copy link
Contributor

@rossta rossta commented Nov 8, 2018

Opening the PR for discussion around a new feature request.

Exposes parsing logic as a public API to allow programmatic inspection of .env files without modifying ENV.

One such use case is for automated application setup to create/read/modify .env files prior to running the application for the first time. I found the need to dive into Dotenv internals to accomplish such a task while debugging installation scripts on a recent project and thought it would be useful to avoid relying on internal details.

@jonmagic
Copy link
Collaborator

jonmagic commented Jan 5, 2019

I might find this useful. Would you mind adding docs to the README and I'll get it shipped?

Exposes parsing logic as a public API to allow programmatic inspection
of .env files without modifying ENV.

One such use case is for automated application setup to
create/read/modify .env files prior to running the application for the
first time.
@rossta
Copy link
Contributor Author

rossta commented Jan 8, 2019

@jonmagic Thanks, updated to document in README.

Copy link
Collaborator

@jonmagic jonmagic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one suggestion. Let me know what you think and I'll get it shipped.

README.md Outdated Show resolved Hide resolved
Co-Authored-By: rossta <rosskaff@gmail.com>
@cadwallion cadwallion merged commit 6a36885 into bkeepers:master Feb 21, 2019
@c9s
Copy link

c9s commented Feb 22, 2019

Hi folks,

we have an use case like this:

dotenv -f .env.test bundle exec rspec --pattern "./spec/models/**/*.rb"

this use case is broken right after the dotenv 2.7.0 release. The --pattern option is consumed by dotenv and therefore it raises an "Unknown option" error. I guess this is related to this PR.

@cadwallion
Copy link
Collaborator

👋 I believe it might actually related to #374 where I implemented an actual options parser. Sorry for the inconvenience this has caused!

I'll take a look at this now.

@cadwallion
Copy link
Collaborator

👋 @c9s I believe you can get the same net effect with the following:

dotenv -f .env.test "bundle exec rspec --pattern './spec/models/**/*.rb'"

The options parser is reading your subsequent script as part of dotenv invocation instead of the command you wish to invoke. I can take a look at alternatives in a separate PR for a future patch, but this should resolve your issue immediately.

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.

4 participants