Not every useful tool needs a web interface, a database server, or a login page. Sometimes the fastest way to solve a problem is a small command-line tool you can run from your terminal in two seconds. That's exactly what I built with Penny a lightweight command-line expense tracker written in Python, powered by the Click library.

Penny lets you add expenses, list them, see a spending summary by category, and clear everything out all from the terminal, with no external database, no server, and no setup beyond installing one dependency. In this post, I'll walk through exactly how it works, file by file, and explain the Click concepts that make it all click.

Why Click?

Python's built-in argparse module can build command-line tools too, but it gets verbose fast. Click takes a different approach: you write regular Python functions and decorate them with @click.command() and @click.option(), and Click handles all the parsing, help text, and validation for you.

The result is CLI code that reads almost like plain Python, which is exactly what you'll see in Penny's commands.py.