just Command runner

Version 1.58.0 · source

Start here

just --init
Create a starter justfile
just
Run the first recipe
just <recipe>
Run a recipe
just <recipe> <arg>
Pass arguments
just --list
Show recipes
just --dry-run <recipe>
Print, don't run
just --choose
Pick with fzf
just --fmt
Tidy the justfile

Concepts

  1. justfile found upwards from cwd
  2. Dependencies run first, once each
  3. Recipe lines each in its own shell
  4. Result stops at first failure

Running

just
Run the default (first) recipe
just <recipe> [<args>...]
Run one or more recipes in order
just --list / just -l
List recipes with doc comments
just --dry-run / just -n
Print recipe lines without running them
just --show <recipe> / just -s <recipe>
Print a recipe's source
just --init
Write a starter justfile in the project root
just --choose
Pick recipes with a chooser (fzf by default)
Set JUST_CHOOSER or pass --chooser to use another picker; recipes needing arguments are not offered.
just --fmt
Rewrite the justfile in canonical style
just <var>=<value> <recipe>
Override a variable for this run
--set <var> <value> is the long form.
just --yes <recipe>
Auto-answer [confirm] prompts
just --quiet / just -q
Suppress all output
just --justfile <file> / just -f <file>
Use a specific justfile
just --global-justfile / just -g
Use the global justfile
just --edit / just -e
Open the justfile in $VISUAL or $EDITOR
just --command <cmd> / just -c <cmd>
Run a command with the justfile's env and .env loaded
just --evaluate [<var>]
Print variables with their values
just --completions <shell>
Print a shell completion script

Recipe syntax

A recipe
# doc comment shown by --listbuild:    cargo build --release
<name>: <dep> <dep>
Run dependencies before the recipe
<name>: <dep> && <after>
Run a dependency after the recipe body
<name>: (<dep> "<arg>")
Pass an argument to a dependency
@<name>:
Don't echo this recipe's lines
@<command>
Don't echo one line
-<command>
Keep going if this line fails
{{<var>}}
Insert a variable or expression into a line
<name> <param>:
Required parameter
<name> <param>=<default>:
Parameter with a default
<name> +<files>:
Variadic: one or more values
<name> *<flags>:
Variadic: zero or more values
<name> $<param>:
Export a parameter as an env var
alias <short> := <recipe>
Another name for a recipe
List recipes when run bare
default:    @just --list
[arg("<param>", long="<opt>")]
Take a parameter as a --option

Variables

<name> := "<value>"
Define a variable
export <NAME> := "<value>"
Export to recipe environments
<name> := `<command>`
Capture a command's output
<a> + <b>
Concatenate strings
<dir> / <file>
Join path parts with a slash
if <a> == <b> { <x> } else { <y> }
Conditional expression
Also !=, =~ (regex match) and &&, ||.
'<text>'
Literal string, no escapes
"<text>"
String with \n \t \" escapes
set dotenv-load
Load .env into the environment
$<NAME>
Read an env var inside a recipe line
env("<NAME>", "<default>")
Env var with fallback
env("<NAME>")
Env var, error if unset
justfile_directory()
Directory of the justfile
invocation_directory()
Directory just was started from
path_exists(<p>)
True if the path exists
require("<tool>")
Path to a tool, error if missing

Settings

set shell := ["bash", "-euo", "pipefail", "-c"]
Choose the shell for lines and backticks
set dotenv-path := "<file>"
Load a specific env file (must exist)
set export
Export all variables
set positional-arguments
Pass args as $1, $2 ... too
set quiet
Don't echo recipe lines
set fallback
Look in parent directories if a recipe is missing

Attributes

[private]
Hide from --list (also names starting with _)
[confirm]
Ask before running
[confirm("<prompt>")]
Ask with a custom prompt
[group("<name>")]
Group recipes in --list
[doc("<text>")]
Set the --list description
[no-cd]
Run in the caller's directory
[working-directory("<dir>")]
Run in a given directory
[linux] / [macos] / [windows] / [unix]
Define the recipe only on that OS
[parallel]
Run dependencies concurrently

Scripts & modules

Shebang recipe
stats:    #!/usr/bin/env python3    import sys    print(sys.version)
Script recipe
[script("python3")]stats:    import sys    print(sys.version)
import "<file>"
Include another justfile's recipes
mod <name>
Load <name>.just or <name>/justfile as a module
just <mod> <recipe> / just <mod>::<recipe>
Run a module's recipe

Recipes

OS-specific recipe
[linux]open:    xdg-open http://localhost:8080[macos]open:    open http://localhost:8080
Build with a version from git
version := `git describe --tags --always`build:    docker build -t app:{{version}} .
Guard a dangerous recipe
[confirm("Deploy to production?")]deploy env="staging": test    ./deploy.sh {{env}}