Been writing makefiles where I want “pass the rest of the args through to this command.” Make’s answer is ugly. Today I learned just has a clean syntax:

test +args:
    pytest {{args}}

cover *args:
    pytest --cov=app {{args}}

+args means “one or more” — the recipe requires at least one argument. *args means “zero or more” — no args is fine.

Now:

just test tests/test_api.py
just test tests/test_api.py -k test_login
just cover
just cover -v --tb=short

Everything after the recipe name gets bundled up and passed through. Much cleaner than the $(MAKECMDGOALS) hack Make needs.

Only gotcha: quoting gets weird if you have args with spaces. just test "foo bar" works, but recipes within recipes that pass args through can lose quoting. If you need bulletproof pass-through, use a shell script.

Also, just has {{justfile_directory()}} if you need an absolute path anchored to the justfile, regardless of cwd. Combined with positional args, you can write recipes that work from any subdirectory.

Rewriting my Makefiles-as-task-runners to Justfiles is a weekend project I keep meaning to finish.