Just make it work

Working on projects, there are adhoc tasks that we need to run to complete a piece of work.

One place to describe these tasks is in the README. Then people wanting to try out the task, can just copy and paste the relevant command into a terminal.

Over time, people might create aliases, shortcuts or even simple shell scripts for these. I am in the shell script and/or alias camp and had tried using make previously, but could not get it to work in a satisfactory manner.

But then I came across just which is a handy way to save and run project-specific commands. Inspired by make, it allows one to specify recipes for these commands in a justfile. Each recipe has

  • a description,
  • a name and
  • the commands to run.

Here is a simple justfile with two simple tasks.

# Hello the world in 2025
 hello:
   echo hello world

# What is special about 2025
 check-2025:
   @echo "45² = 2025"
   @echo "(1³ + 2³ + 3³ + 4³ + 5³ + 6³ + 7³ + 8³ + 9³ ) = 2025"
   @echo "(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)² = 2025"
            

Running just --list will show the recipes that can be run:

$ just --list
 Available recipes:
     hello      # Hello the world in 2025
     check-2025 # What is special about 2025
            

Then running just check-2025 will run the recipe:

$ just check-2025
 5²  = 2025
 (1³ + 2³ + 3³ + 4³ + 5³ + 6³ + 7³ + 8³ + 9³ ) = 2025
 (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)² = 2025
            

By default, running just without any parameters will run the first recipe:

$ just
 echo hello world
 hello world
            

However just provides a way of specifying the default recipe to run. So a common practice is to make the default recipe list the available tasks.

@_default:
   just --list --unsorted

# Hello the world in 2025
 hello:
   echo hello world

# What is special about 2025
 check-2025:
   @echo "45² = 2025"
   @echo "(0³+ 1³ + 2³ + 3³ + 4³ + 5³ + 6³ + 7³ + 8³ + 9³ ) = 2025"
   @echo "(0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)² = 2025"
            

And running just now shows what can be done.

$ just
 Available recipes:
     hello      # Hello the world in 2025
     check-2025 # What is special about 2025

            

Some of the great things about the project are that it is cross-platform, is actively maintained and has pretty good documentation.