Formatting and dumping justfiles
Each justfile has a canonical formatting with respect to whitespace and
newlines.
You can overwrite the current justfile with a canonically-formatted version
using the --fmt flag:
$ cat justfile
# A lot of blank lines
some-recipe:
echo "foo"
$ just --fmt
$ cat justfile
# A lot of blank lines
some-recipe:
echo "foo"
When the justfile is read from standard input with --justfile - or
extracted from a markdown file, --fmt prints the formatted justfile to
stdout.
Note that formatting is not covered by any backwards compatibility guarantee and is subject to change from time to time.
Recipe bodies are indented with four spaces by default. This can be changed
with the --indentation command-line option, the JUST_INDENTATION
environment variable, or the indentation setting:
set indentation := " "
Invoking just --fmt --check runs --fmt in check mode. Instead of
overwriting the justfile, just will exit with an exit code of 0 if it is
formatted correctly, and will exit with 1 and print a diff if it is not.
You can use the --dump command to output a formatted version of the
justfile to stdout:
$ just --dump > formatted-justfile
The --dump command can be used with --dump-format json to print a JSON
representation of a justfile.