tally, with the author's exact versions

We build tally, a small word counter, one change at a time. It begins as a command with nothing to count. At the end, it counts the words of a file, has tests and types, and writes a report of the most common words. Every command runs through uv, in the project's own environment.

We make tally in moves. A move is one small change, made by one patch or by one command. A patch changes a file, and a command such as uv add writes the files it needs.

Each move first says what problem it solves. Then it gives the change, piece by piece. Last, a command checks the result, and a list names each file that changed, with what to look for in it.

There are two ways to read this tutorial. Both have the same parts, in the same order.

Each part ends with a section called What changed. It lists every file that the part changes, with a link to the file, and then the whole diff of each file, folded. A lockfile and a binary file have a link alone. The text above it explains the change. In Build it yourself, What changed is what you check your files against.

In Build it yourself, a file that a command makes says which command. A diff that is open is a patch. Apply it with the command in the text, or make the same change in your editor.

Read the tutorial

Each change explained, with the code to look at.

Build it yourself

Every command to run and every change to make by hand, to make the project yourself.

Get the project

You build the project in a clone of your own, on a branch mine that starts where this walk starts. Run the commands of these pages in its top folder.

git clone https://github.com/rahuldave/tally
cd tally
git switch -c mine 6a63758166d3

Then add the command git check, which compares your files with the project's after each move, and leaves what git add has staged as it was.

git config alias.check '!f() { i="$(git rev-parse --git-path check-index)" && { cp -p "$(git rev-parse --git-path index)" "$i" 2>/dev/null || rm -f "$i"; } && export GIT_INDEX_FILE="$i" && git add -A && git diff --cached --stat "$1"; }; f'

The parts