-
Notifications
You must be signed in to change notification settings - Fork 454
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
Detail environment variables usage in README.md #1086
Changes from all commits
23ec017
6db6d50
7ccc7e2
10bb002
daab432
b5cc45e
1b62dbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -715,7 +715,7 @@ Available recipes: | |
|
||
### Dotenv Integration | ||
|
||
If `dotenv-load` is set to `true`, `just` will load environment variables from a file named `.env`. This file can be located in the same directory as your `justfile` or in a parent directory. These variables are environment variables, not `just` variables, and so must be accessed using `$VARIABLE_NAME` in recipes and backticks. | ||
If [`dotenv-load`](#dotenv-load) is set, `just` will load environment variables from a file named `.env`. This file can be located in the same directory as your `justfile` or in a parent directory. These variables are environment variables, not `just` variables, and so must be accessed using `$VARIABLE_NAME` in recipes and backticks. | ||
|
||
For example, if your `.env` file contains: | ||
|
||
|
@@ -899,6 +899,18 @@ This is an x86_64 machine | |
|
||
- `env_var(key)` — Retrieves the environment variable with name `key`, aborting if it is not present. | ||
|
||
```make | ||
home_dir := env_var('HOME') | ||
|
||
test: | ||
echo "{{home_dir}}" | ||
``` | ||
|
||
```sh | ||
$ just | ||
/home/user1 | ||
``` | ||
|
||
- `env_var_or_default(key, default)` — Retrieves the environment variable with name `key`, returning `default` if it is not present. | ||
|
||
#### Invocation Directory | ||
|
@@ -1140,7 +1152,9 @@ $ just --set os bsd | |
./test --test bsd | ||
``` | ||
|
||
### Environment Variables | ||
### Getting and Setting Environment Variables | ||
|
||
#### Exporting `just` Variables | ||
|
||
Assignments prefixed with the `export` keyword will be exported to recipes as environment variables: | ||
|
||
|
@@ -1174,6 +1188,30 @@ a $A $B=`echo $A`: | |
echo $A $B | ||
``` | ||
|
||
When [export](#export) is set, all `just` variables are exported as environment variables. | ||
|
||
#### Getting Environment Variables from the environment | ||
|
||
Environment variables from the environment are passed automatically to the recipes. | ||
|
||
```make | ||
print_home_folder: | ||
echo "HOME is: '${HOME}'" | ||
``` | ||
|
||
```sh | ||
$ just | ||
HOME is '/home/myuser' | ||
``` | ||
#### Loading Environment Variables from a `.env` File | ||
|
||
`just` will load environment variables from a `.env` file if [dotenv-load](#dotenv-load) is set. The variables in the file will be available as environment variables to the recipes. See [dotenv-integration](#dotenv-integration) for more information. | ||
|
||
#### Setting `just` Variables from Environments Variables | ||
|
||
Environment variables can be propagated to `just` variables using the functions `env_var()` and `env_var_or_default()`. | ||
See [environment-variables](#environment-variables). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two sections called "Environment Variables". Maybe we could rename Environment Variables(after Setting Variables from the Command Line) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right, so linking doesn't work? How about "Getting and Setting Environment Variables" as the header for the section that starts with "Assignments prefixed with the export keyword…"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Linking worked, but it is a bit harder to navigate in the table of content. I edited as you proposed |
||
|
||
### Recipe Parameters | ||
|
||
Recipes may have parameters. Here recipe `build` has a parameter called `target`: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code blocks with
make
syntax are extracted and parsed, to make sure that they're correct syntax, so the test is failing when it reaches/home/user
. This should be wrapped in a separate code block of typesh
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed.