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 support for command line env variables #56

Closed
PatrikValkovic opened this issue Oct 8, 2021 · 3 comments
Closed

Add support for command line env variables #56

PatrikValkovic opened this issue Oct 8, 2021 · 3 comments

Comments

@PatrikValkovic
Copy link
Contributor

This feature is similar to what cross-emv does.
Sometimes, I want to import variables both from the file and from the command line.
It would be nice if dotenv-cli would be the multiplatform tool to do that.

Proposal

Add new option to load variables from command line. For example -v:

dotenv -e ./config/.env -e ./config/.env.dev -v DB_HOST=localhost -v DB_USER=root -v DB_PASS=root -- node ./scripts/something.js

or maybe just use of single option

dotenv -e ./config/.env -e ./config/.env.dev -v DB_HOST=localhost DB_USER=root DB_PASS=root -- node ./scripts/something.js
dotenv -e ./config/.env -e ./config/.env.dev -v DB_HOST=localhost;DB_USER=root;DB_PASS=root -- node ./scripts/something.js

(Just suggestion, I would prefer most the first way)

Right now the solution would need to use both cross-env and dotenv-cli

cross-env DB_HOST=localhost DB_USER=root DB_PASS=root  dotenv -e ./config/.env -e ./config/.env.dev -- node ./scripts/something.js
@entropitor
Copy link
Owner

I'm guessing you're worried about cross-compatibility with windows and that's why:

DB_HOST=localhost DB_USER=root DB_PASS=root dotenv -e ./config/.env -e ./config/.env.dev -- node ./scripts/something.js

wouldn't work?

I'm open to a PR if that's the reason. I don't want this to became a really large package but I think that's still a reasonable extension

@PatrikValkovic
Copy link
Contributor Author

Yes, I am concerned about cross-compatibility and Windows (of course).
I may try to come with some PR, hovewer what do you think should be the preferred way?

@entropitor
Copy link
Owner

Ah sorry, the first option seems the best then indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants