TL;DR
- Checkout the project’s GitHub: https://github.com/casey/just and official guide
- Install just:
- Arch Linux:
pacman -Syu just
- Ubuntu:
apt install just
- MacOS:
brew install just
- checkout the README for detailed info
- Arch Linux:
- create a justfile:
touch justfile
- Get started: open the justfile and insert:
# List all available recipes
[private]
default:
just --list
# echos "hello"
echo-hello:
echo "Hello"
- type
just echo-hello
in your terminal and press enter - type
just
in your terminal and press enter
Exemplary Content Explained
# List all available recipes
[private]
default:
just --list
# echos "hello"
echo-hello:
echo "Hello"
- lines with hashes are the info listed when “just –list” is executed
- [private] leads to the recipe not being displayed when you execute “just –list”
- default is the default recipe executed when you only type “just” and press enter. We set it to “just –list” which lists all available commands
- “echo-hello” is a recipe
Output of “just” and “just echo-hello” - what is what?
When you entered “just”, the command defined by the recipe “default” was executed: “just –list”. In consequence, all available recipes are listed. We see that “echo-hello” is available. Behind it we see our explanatory comment that says that the recipe “echo-hello” echoes “hello”.
When we executed the recipe “echo-hello”, we see the command that was executed by the recipe “echo ‘Hello’” and its output, which is a plain “Hello”.
Attributes
We already got to know the [default] and [private] attribute earlier. There are more helpful attributes you can use:
attribute | description |
---|---|
[confirm] | leads to the need for the user to confirm the recipe execution |
[no-cd] | by default, recipes run in the working directory set to the directory that contains the justfile. no-cd leads to the working directory being set to the directory where just was invoked in |
[working-directory: ‘somedir’] | you can override the directory for a specific recipe |
[doc(’the documentation’)] | add documentation for a recipe but the documentation will not show as description when running just --list |
There a even more attributes in the official documentation
Facts & Features
Some facts..
- the syntax of just was inspired by make
- just is a command runner however, not a build system
- Linux, MacOS and Windows are supported without additional dependencies
- a GitHub Action is available: “extractions/setup-just@v3”
- starting from version 1.0 the maintainers commited themselves to ensure backwards compatibility
- syntax highlighting in IDEs is supported via plugins. Due to its inspiration from make, a makefile syntax highlighter also works for just
- you can chain recipes. I often do: just install start (install project dependencies and start project. Those are custom recipes I wrote for my projects, they are not predefined by just)
- you can extend a general justfile with a custom one by importing another justfile at the top of your default justfile (pay respect to duplicate recipes etc. See the available settings for more information)
…and Features
Feature | Description |
---|---|
Command Line Arguments | Recipes can accept command line arguments. |
Environment Variables | just loads .env files; access them with the env(key) function. |
Aliases | just supports aliases. |
Concatenation | just supports concatenation with “+”. |
Logical Operators | just supports logical operators (&& and || ) |
Conditional Statements | just supports conditional statements. |
Built-in Functions | Built-in functions are available for just and OS-related topics, and also for string manipulation and many more. |
Shell Support | You can write shell in just. |
Predefined Constants & Imports | You can extend a general justfile with a custom one by importing another justfile at the top of your default justfile (pay respect to duplicate recipes, etc. See the available settings for more information). |
I only listed the sections I needed most during my career, but I think the whole README is worth taking a look if you start using just.