just
is a handy way to save and run project-specific commands.
(非官方中文文档,这里,快看过来!)
Commands, called recipes, are stored in a file called justfile
with syntax inspired by make
:
build:
cc *.c -o main
# test everything
test-all: build
./test --all
# run a specific test
test TEST: build
./test --test {{TEST}}
You can then run them with just RECIPE
:
$ just test-all
cc *.c -o main
./test --all
Yay, all your tests passed!
Just has a ton of useful features, and many improvements over Make:
-
Just is a command runner, not a build system, so it avoids much of Make’s complexity and idiosyncrasies. No need for
.PHONY
recipes! -
Linux, MacOS, and Windows are supported with no additional dependencies. (Although if your system doesn’t have an
sh
, you’ll need to choose a different shell.) -
Errors are specific and informative, and syntax errors are reported along with their source context.
-
Recipes can accept command line arguments.
-
Wherever possible, errors are resolved statically. Unknown recipes and circular dependencies are reported before anything runs.
-
Just loads
.env
files, making it easy to populate environment variables. -
Recipes can be listed from the command line.
-
Command line completion scripts are available for most popular shells.
-
Recipes can be written in arbitrary languages, like Python or NodeJS.
-
just
can be invoked from any subdirectory, not just the directory that contains theJustfile
. -
And much more!
If you need help with just
please feel free to open an issue or ping me on discord. Feature requests and bug reports are always welcome!
- Installation
- Quick Start
- Examples
- Features
- Listing Available Recipes
- Aliases
- Settings
- Documentation Comments
- Variables and Substitution
- Strings
- Ignoring Errors
- Functions
- Command Evaluation Using Backticks
- Conditional Expressions
- Setting Variables from the Command Line
- Environment Variables
- Recipe Parameters
- Running recipes at the end of a recipe
- Writing Recipes in Other Languages
- Safer Bash Shebang Recipes
- Setting Variables in a Recipe
- Multi-line Constructs
- Command Line Options
- Private Recipes
- Quiet Recipes
- Selecting Recipes to Run With an Interactive Chooser
- Invoking Justfiles in Other Directories
- Just Scripts
- Miscellanea
- Contributing
- Frequently Asked Questions
- Further Ramblings
just
should run on any system with a reasonable sh
, including Linux, MacOS, and the BSDs.
On Windows, just
works with the sh
provided by Git for Windows, GitHub Desktop, and Cygwin.
If you’d rather not install sh
, you can use the shell
setting to use the shell of your choice.
Like cmd.exe
:
# use cmd.exe instead of sh:
set shell := ["cmd.exe", "/c"]
list:
dir
…or Powershell:
# use Powershell instead of sh:
set shell := ["powershell.exe", "-c"]
hello:
Write-Host "Hello, world!"
Operating System | Package Manager | Package | Command |
---|---|---|---|
|
|||
|
|||
|
|||
|
|||
just AUR |
|
||
|
|||
|
|||
|
|||
|
|||
|
Pre-built binaries for Linux, MacOS, and Windows can be found on the releases page.
You can use the following command on Linux, MacOS, or Windows to download the latest release, just replace DEST
with the directory where you’d like to put just
:
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to DEST
See Installation for how to install just
on your computer. Try running just --version
to make sure that it’s installed correctly.
Once just
is installed and working, create a file named justfile
in the root of your project with the following contents:
recipe-name:
echo 'This is a recipe!'
# this is a comment
another-recipe:
@echo 'This is another recipe.'
When you invoke just
it looks for file justfile
in the current directory and upwards, so you can invoke it from any subdirectory of your project.
The search for a justfile
is case insensitive, so any case, like Justfile
, JUSTFILE
, or JuStFiLe
, will work.
Running just
with no arguments runs the first recipe in the justfile
:
$ just
echo 'This is a recipe!'
This is a recipe!
One or more arguments specify the recipe(s) to run:
$ just another-recipe
This is another recipe.
just
prints each command to standard error before running it, which is why echo 'This is a recipe!'
was printed. This is suppressed for lines starting with @
, which is why echo 'Another recipe.'
was not printed.
Recipes stop running if a command fails. Here cargo publish
will only run if cargo test
succeeds:
publish:
cargo test
# tests passed, time to publish!
cargo publish
Recipes can depend on other recipes. Here the test
recipe depends on the build
recipe, so build
will run before test
:
build:
cc main.c foo.c bar.c -o main
test: build
./test
sloc:
@echo "`wc -l *.c` lines of code"
$ just test
cc main.c foo.c bar.c -o main
./test
testing... all tests passed!
Recipes without dependencies will run in the order they’re given on the command line:
$ just build sloc
cc main.c foo.c bar.c -o main
1337 lines of code
Dependencies will always run first, even if they are passed after a recipe that depends on them:
$ just test build
cc main.c foo.c bar.c -o main
./test
testing... all tests passed!