Skip to content

Commit

Permalink
Document new features (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jul 22, 2021
1 parent 77bba3e commit 985f150
Showing 1 changed file with 61 additions and 5 deletions.
66 changes: 61 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,26 @@ bar foo:
Note the space after the final `}`! Without the space, the interpolation will
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

Variables can be overridden from the command line.
Expand Down Expand Up @@ -1073,20 +1093,23 @@ foo $bar:

=== 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
a:
echo 'A!'

b: a
b: a && c d
echo 'B!'
just c

c:
echo 'C!'

d:
echo 'D!'
```

…running 'b' prints:
Expand All @@ -1099,9 +1122,42 @@ echo 'B!'
B!
echo 'C!'
C!
echo 'D!'
D!
```

=== 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 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.
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

Expand Down

0 comments on commit 985f150

Please sign in to comment.