Skip to main content

Project: a command-line tool in Python

Published on November 3, 2026 · Updated on November 28, 2026

Milestone by milestone, you'll build `ordena`: a command-line tool in Python that brings order to a chaotic downloads folder. In two minutes, the first lesson shows you how a naive script loses a file; from there you build the version that loses nothing. You scan the files, classify them by type and by month, detect duplicates by content, propose a move plan that never overwrites, and apply it only once you confirm, with an undo log that works even if the process is interrupted. Then you give it an argparse interface with correct exit codes, TOML configuration with flag > file > default priority, a pytest test suite, and a pyproject.toml with a README. You test every command by calling `main` with its arguments on test folders, and you finish with a challenge on a folder you've never seen. Everything happens on the course page, in about 7.5 hours. You need to know how to write functions, work with files and exceptions, and have written at least one test.

lessons
20
modules
8
of content
7 h 38 min

A sample lesson

python
from dataclasses import dataclass
from pathlib import Path


@dataclass(frozen=True)
class Movimiento:
    origen: Path    # where the file is today
    destino: Path   # where it will end up if the plan is applied


def describir(plan, raiz):
    """Devuelve líneas de texto; solo la CLI las imprime."""
    return [f"{m.origen.relative_to(raiz)} -> "
            f"{m.destino.relative_to(raiz)}" for m in plan]

Available in: EN · ES

By the end, you'll be able to

  • Design and build a CLI with argparse featuring subcommands, validated options, text or JSON output, and correct exit codes
  • Write pytest tests on temporary folders that fail when someone plants a bug in the tool
  • Turn expected errors into clear messages without tracebacks and protect destructive operations with simulation and undo
  • Package your own tool with pyproject.toml and an entry point that declares it as a command

Course content

20
7 notebooks3 interactive lessons1 reading9 more lessons

Worth knowing first

Courses and skills worth covering first to get the most out of this one (a suggestion, not a requirement).

Related skills

Skills from the map that this course helps you build.

Prepares you for

Mastering this course brings you closer to these skills.

Advances these routes

This course is part of broader learning paths.

Frequently asked questions

How long is Project: a command-line tool in Python?

20 lessons and about 7 h 38 min of content. You go at your own pace, with no fixed dates.

What will you learn in Project: a command-line tool in Python?

By the end you will be able to: Design and build a CLI with argparse featuring subcommands, validated options, text or JSON output, and correct exit codes; Write pytest tests on temporary folders that fail when someone plants a bug in the tool; Turn expected errors into clear messages without tracebacks and protect destructive operations with simulation and undo.

Similar content

Other courses, projects and specializations related to this content.

Course · Beginner · 5 h · Available in Spanish, English:

Practical Python: files and debugging

Read and write CSV and JSON files with Python's standard library

Free