Command-Line To-Do List Manager in Lua
Build a to-do list manager for the terminal in Lua. You run commands like lua todo.lua add "Buy milk", lua todo.lua list, lua todo.lua done 2 and lua todo.lua remove 3, and your tasks are saved in a text file, so they're still there next time. The list shows numbered tasks with a mark for finished ones. It's a perfect first Lua project: you'll learn tables, string formatting, reading and writing files, reading command-line arguments, and handling mistakes such as a task number that doesn't exist.
- Estimate
- ~6.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Lua standard library
Project roadmap
- 01
Set up the script
~0.5hCreate todo.lua. Keep tasks in a table where each task is a table with text and done fields. Read the command from the arg table (arg[1] is the command, the rest are its values), and print a usage message listing all commands when no command or an unknown one is given. Done when: running the script without arguments prints the usage.
- 02
Save and load tasks
~1.5hWrite load_tasks and save_tasks using io.open. Store one task per line as 0 or 1 (done), a tab, then the text. When the file doesn't exist, start with an empty list. Skip lines in the wrong format with a warning instead of crashing. Done when: tasks saved by one run are loaded by the next.
- 03
Add the commands
~1.5hImplement add "text" (join the remaining arguments into the text), list, done N, undo N, remove N and clear-done (remove all finished tasks). Save the file after every change. Done when: every command works and changes are kept between runs.
- 04
Format the list
~1hPrint the tasks with string.format, like 1. [x] Buy milk and 2. [ ] Call mom, with the numbers aligned. Print a summary line such as 1 of 2 done, and a friendly message when the list is empty. Done when: the list is neatly aligned, also with 10 or more tasks.
- 05
Handle mistakes
~1hHandle an empty task text, a task number that isn't a number or doesn't exist (show the valid range), and adding a task that already exists and isn't done (ask with a warning, or refuse). Print errors to stderr with io.stderr:write and exit with os.exit(1). Done when: each mistake prints a clear message, and the file is never damaged.
- 06
Test it
~1hWrite test.lua that uses a temporary file and plain assert calls to check adding, completing, removing, saving and loading, and each error case. Done when: running lua test.lua finishes without assertion errors.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack