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

1748-dotenv-files #2022

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

1748-dotenv-files #2022

wants to merge 1 commit into from

Conversation

sbeckeriv
Copy link

Dearest Reviewer,

I was looking at the parser and the format for a list of things [] was already support for shells. I reused that concept to make an ordered list of strings.

This now works

set dotenv-files := [".env1", ".env2"]

As does the command line

just --dotenv-files .env1 --dotenv-files .env2 echo

The new setting is applied last. It does not change how the other two settings currently work.

I do have a problem I cant get this to work

ENV := "prod"
set dotenv-files := [".env.{{ENV}}", ".env"]

it the {{ENV}} never turns in to prod. I am using parse_string_literal.

the issue #1748 asked about fallback justfiles. I have not used them and I would take any advice on what to change for that as well.

Any advice would be appreciated

Thanks
Becker

Dearest Reviewer,

I was looking at the parser and the format for a list of things [] was
already support for shells. I reused that concept to make an ordered list
of strings.

This now works
```
set dotenv-files := [".env1", ".env2"]
```

As does the command line
```
just --dotenv-files .env1 --dotenv-files .env2 echo
```

The new setting is applied last. It does not change how the other two settings
currently work.

I do have a problem I cant get this to work
```
ENV := "prod"
set dotenv-files := [".env.{{ENV}}", ".env"]
```
it the `{{ENV}}` never turns in to prod.  I am using parse_string_literal.

the issue was updated about fallback justfiles. I have not used them and I would
take any advice on what to change for that as well.

Any advice would be appreciated

Thanks
Becker
@omar25h
Copy link

omar25h commented May 12, 2024

Not very related to the PR, but to my knowledge, the ".env.{{ENV}}" is working as expected since interpolation only works in recipes. The alternative would be to write something like:

ENV := "prod"
set dotenv-files := [".env."+ENV, ".env"]

@casey
Copy link
Owner

casey commented May 19, 2024

Does this need to be a separate setting? I strikes me that set dotenv-file could be extended to accept either a single item, or an array of items, with a single item being equivalent to an array containing that single item. Additionally, the --dotenv-filenname could be changed to accept multiple items.

@sbeckeriv
Copy link
Author

Does this need to be a separate setting? I strikes me that set dotenv-file could be extended to accept either a single item, or an array of items, with a single item being equivalent to an array containing that single item. Additionally, the --dotenv-filenname could be changed to accept multiple items.

I made the new setting in response to the comment here #1748 (comment).

Originally I had setting it more then once here #1940.

I could redo dotenv-file take a string or list with the current dotenv-file and accept the command line multiple times. Kind of munging the two PRs together.

The parse_ordered_list i wrote only works with static strings. I have not figured out how to get an expression working ie: ".env."+ENV. I would need some pointers or an example on how i can handle that correctly.

@casey
Copy link
Owner

casey commented May 20, 2024

I made the new setting in response to the comment here #1748 (comment).

Originally I had setting it more then once here #1940.

I think having a single setting that takes an array is a better idea. Otherwise, the two settings conflict.

The parse_ordered_list i wrote only works with static strings. I have not figured out how to get an expression working ie: ".env."+ENV. I would need some pointers or an example on how i can handle that correctly.

It will have to take a static string. dotenv file settings are applied before anything in the justfile is evaluated, so it can't use variables. I did merge #2055 recently, which adds a new kind of string literal which can contain environment variables, so those can be used.

@casey
Copy link
Owner

casey commented May 20, 2024

Also, this needs tests, including tests which cover how different ways dotenv files can be specified interact with each other.

@casey casey marked this pull request as draft May 25, 2024 08:10
@casey
Copy link
Owner

casey commented May 25, 2024

Converting to a draft so I can keep track of what's ready to go. Feel free to undraft when it's ready!

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.

3 participants