Just run commands

just is a simple command runner, and an alternative to GNU Make. If you ever found yourself creating bunch of small scripts (build.sh, setup.sh, install.sh). If you documented long commands in Markdown snippets, just can help make that easier to use and organize. Similarly to npm run <task>, make <task> or other arbitrary commands executor, you define keys with one or more commands. It is quite funny when some commands are like oral sentences: just build the program.

Setup just

# Fedora
sudo dnf install -y just
# Ubuntu
sudo apt install -y just
# Arch
sudo pacman -S just

# Windows
winget install --id Casey.Just --exact

# MacOS
brew install just

If not listed here, look at the commands for installation via a package manager

Quick demo

We suggest you to create a C++ + CMake + Google Test project (you can do it quickly with scr cpp-cmake-gtest). Then, just create a file named justfile with the following content.

# Build with CMake
build:
    cmake . -Bbuild && cmake --build build/ -j 8
# Run the program
run:
    build/exo
# Run the tests
test:
    build/tests
# Run the program in watch mode
watch:
    ls *.h *.cpp | entr -c -c sh -c "just build && just run"
# Run tests in watch mode
watch-test:
    ls *.h *.cpp | entr -c -c sh -c "just build && just test"

This file is just creating 5 so-called recipies with a single command associated. Several commands one after the other is also supported.

just has a list flag to see the available recipies. It extracts comments to document their goal.

> just -l
Available recipes:
    build      # Build with CMake
    run        # Run the program
    test       # Run the tests
    watch      # Run the program in watch mode
    watch-test # Run tests in watch mode

Now running just build, then just run would be enough to run the associated commands ! You can know imagine how simple it will be to explain that in your docs ! Want to run tests ? just test. Run it on each change ? just watch-test.

Note: if you are using Runox, you probably know that these shortcuts are not needed for this standard commands with C++ and CMake, but using Just would be beneficial for projects that have more exotic commands.

Niceties of Just

To become more than just a beginner in this tool (pun intended), there is more to learn on their documentation... If you are lazy, just follow a few more tips here.

Using arguments in recipies

TODO

Auto-completion

You'll even get auto-completion of available tasks, with their associated comment !

> just watch-
watch  (Run the program in watch mode)  watch-test  (Run tests in watch mode)

More examples

Ramblings about Just

The author wrote a nice page: https://just.systems/man/en/further-ramblings.html