Document new features (#914)

This commit is contained in:
Casey Rodarmor 2021-07-22 00:51:42 -07:00 committed by GitHub
parent 77bba3ee0e
commit 985f15004f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -879,6 +879,26 @@ bar foo:
Note the space after the final `}`! Without the space, the interpolation will Note the space after the final `}`! Without the space, the interpolation will
be prematurely closed. be prematurely closed.
Multiple conditionals can be chained:
```make
foo := if "hello" == "goodbye" {
"xyz"
} else if "a" == "a" {
"abc"
} else {
"123"
}
bar:
@echo {{foo}}
```
```sh
$ just bar
abc
```
=== Setting Variables from the Command Line === Setting Variables from the Command Line
Variables can be overridden from the command line. Variables can be overridden from the command line.
@ -1073,20 +1093,23 @@ foo $bar:
=== Running Recipes at the End of a Recipe === Running Recipes at the End of a Recipe
Dependencies of a recipes always run before a recipe starts. That is to say, the dependee always runs before the depender. Normal dependencies of a recipes always run before a recipe starts. That is to say, the dependee always runs before the depender. These dependencies are called "prior dependencies".
A recipe can also have subsequent dependencies, which run after the recipe and are introduced with an `&&`:
You can call `just` recursively to run a recipe after a recipe ends. Given the following justfile:
```make ```make
a: a:
echo 'A!' echo 'A!'
b: a b: a && c d
echo 'B!' echo 'B!'
just c
c: c:
echo 'C!' echo 'C!'
d:
echo 'D!'
``` ```
…running 'b' prints: …running 'b' prints:
@ -1099,9 +1122,42 @@ echo 'B!'
B! B!
echo 'C!' echo 'C!'
C! C!
echo 'D!'
D!
``` ```
This has some limitations, since recipe `c` is run with an entirely new invocation of `just`: Assignments will be recalculated, dependencies might run twice, and command line arguments will not be propagated to the child `just` process. === Running Recipes in the Middle of a Recipe
`just` doesn't support running recipes in the middle of another recipe, but you can call `just` recursively in the middle of a recipe. Given the following justfile:
```make
a:
echo 'A!'
b: a
echo 'B start!'
just c
echo 'B end!'
c:
echo 'C!'
```
…running 'b' prints:
```sh
$ just b
echo 'A!'
A!
echo 'B start!'
B start!
echo 'C!'
C!
echo 'B end!'
B end!
```
This has limitations, since recipe `c` is run with an entirely new invocation of `just`: Assignments will be recalculated, dependencies might run twice, and command line arguments will not be propagated to the child `just` process.
=== Writing Recipes in Other Languages === Writing Recipes in Other Languages