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

Feature: automatic .env reading #152

Open
vanodevium opened this issue Jan 30, 2025 · 8 comments
Open

Feature: automatic .env reading #152

vanodevium opened this issue Jan 30, 2025 · 8 comments

Comments

@vanodevium
Copy link

golang can read .env
so it would be nice to have ability automatic reading .env from cwd

@yassinebenaid
Copy link
Owner

Nice suggestion 🔥 . I would love to see this in bunster .

The implementation design would be to have a builtin that automatically loads from a file:

Example:

# load from a file
envload file.env

# loads from file named .env
envload 

what do you think

@yassinebenaid yassinebenaid added enhancement New feature or request feature-request and removed enhancement New feature or request labels Jan 30, 2025
@vanodevium
Copy link
Author

@yassinebenaid
Nice. Also it can be useful as build parameter:

bunster build --envload

@yassinebenaid
Copy link
Owner

What I understand from your suggestion is the following:

  1. you build a program like this:
bunster build script --envload
  1. the compiler will automaticaly read from .env and embeds the values into the binary.
  2. The variables will be available as variables at runtime.

Correct me if I'm wrong !

@vanodevium
Copy link
Author

I have to correct you

I want to load variables from .env (or other naming) when I run already built binary.

Lets imagine: I build binary and push it to the remote host.

So, if there would be .env file in folder, where i launch binary, it will try to read and parse that .env and use variables in runtime.

few word about build parameter

bunster build script --envload: this variant will be try to read .env file
bunster build script --envload=foo.bar: this variant will be try to read foo.bar file

@yassinebenaid
Copy link
Owner

yassinebenaid commented Jan 30, 2025

Ammm, I wonder why would you prefer that over using the envload command. Apparently, it's the same with two different methods.

I mean, if both methods do the same thing, why don't we just keep one of them. I vote for first one.

The envload is going to be builtin command, you don't need any external program. Also, It will allow you to do a lot of tricks. such as:

# in condition
if true; then
    envload   
fi

# in sub-shell
(
     envload   
)

# ...

@vanodevium
Copy link
Author

@yassinebenaid Sounds good. Ok.

@vanodevium
Copy link
Author

@yassinebenaid But don't forget support custom file naming, not only .env, please

@yassinebenaid
Copy link
Owner

don't forget support custom file naming, not only .env

Yep, sure.

It'll be added soon in a future release.

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