๐ŸŽ™ Free live masterclass ยท Sun, 29 Nov, 7:00 pm IST ยท Java Full Stack roadmap Register free โ†’
Skills101

Command-line to-do app

A to-do manager you run from the terminal: add, list, complete and delete tasks, saved to a file.

Beginnerโฑ 3โ€“5 hours๐Ÿชœ 7 stepsPythonJSONargparse

What you'll learn

  • โ—†Command-line arguments with argparse
  • โ—†Reading and writing JSON
  • โ—†Organising code into functions and modules

What you'll build

  • โœ“todo add "Buy milk" --due 2026-12-01
  • โœ“todo list (pending first, overdue in red)
  • โœ“todo done 3 and todo delete 3
  • โœ“Tasks saved in tasks.json

Step-by-step guide

  1. 1

    Design the data

    Each task is a dict: {"id": 1, "title": "...", "due": "2026-12-01", "done": false}. All tasks live in a list saved to tasks.json.

  2. 2

    Load and save

    Write load_tasks() (return [] if the file does not exist) and save_tasks(tasks) using json.load / json.dump with indent=2.

  3. 3

    Set up argparse sub-commands

    Create a parser with add_subparsers(): add (title, --due), list, done (id), delete (id).

  4. 4

    Implement add and list

    add assigns the next id (max id + 1). list prints a table with id, title, due date and status; sort pending tasks by due date.

  5. 5

    Implement done and delete

    Find the task by id, show a friendly error if it does not exist, then update or remove it and save.

  6. 6

    Highlight overdue tasks

    Compare due with datetime.date.today(); print overdue rows in red using ANSI codes (\033[31m ... \033[0m).

  7. 7

    Make it installable

    Add a pyproject.toml with a [project.scripts] entry so pip install -e . gives you a real "todo" command.

๐Ÿš€ Make it stand out

  • +Add priorities and tags with filtering
  • +Switch storage to SQLite
  • +Add a weekly summary command