Just run commands
just is a simple command runner, as an alternative to GNU Make. If you ever found yourself creating bunch of small scripts like build.sh, setup.sh, install.sh, clean.sh, or documenting long command snippets in Markdown files, this project will help you organizing snippets and documenting them.
Similarly to npm run <task>, make <task> or other arbitrary commands executor, you just need to defines keys that contains one or more commands.
Quick demo
To quickly test the power of this, I suggest you to create a C++ + CMake + Google Test project (you can do that 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)