Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Watch mode: the core loop

Running cmetal with no arguments starts watch mode — the experience the tool is built around. It picks up at your first unsolved exercise and stays there, watching the file, until you solve it.

What it does

  1. It shows the current exercise: its name, the path to its .c file under my_exercises/, and its current status.
  2. It watches my_exercises/ for changes.
  3. Every time you save the exercise file, cmetal recompiles it, runs it, and re-verifies — no keypress needed. The screen updates in place with the new result (a compile error, a failed assertion, a sanitizer report, or a green pass).
  4. When the exercise passes, its solution unlocks in my_solutions/ and you move on with n.

The unit of feedback is a file save. You never leave your editor to "run" anything; saving is running.

Reading a result

A result is one of a few shapes:

  • Compile error — the compiler's own output, verbatim. The most common early result; the message is the lesson.
  • Runtime failure — the program compiled and ran, but signalled failure (a non-zero exit, or a failed test assertion when the exercise has tests).
  • Sanitizer report — for exercises with sanitizers enabled, AddressSanitizer or UBSan caught something at runtime (a use-after-free, an overflow, a leak). This is the whole point of the UB Lab exercises.
  • Pass — green. The solution unlocks.

What exactly is compiled and run — and with which flags — is spelled out in How verification works.

Keys

KeyAction
nMove to the next exercise
pMove to the previous exercise
hReveal the next hint (they accumulate)
lList every exercise with its status
rRe-run the current exercise now
qQuit (progress is saved)

r is useful when a result depends on something outside the file — you changed a compiler with --compiler, or you just want to force a fresh run.

Progress persists

Your position and which exercises you've solved are written to .cmetal-state.txt in your workspace. Quit whenever; the next cmetal resumes exactly where you were. To wipe it and start clean, use cmetal reset.

When you don't want the loop

Watch mode is for working through the curriculum. For one-off actions — running a single exercise, listing progress, re-opening a solution — the subcommands do the job without entering the loop.