Add the add, list, and done commands. Replace this with your step instructions.
Instructions
- Read the subcommand from
sys.argv - Implement
add,list, anddone - Store todos in a JSON file
Dispatch the subcommand
main reads the subcommand from sys.argv[1] and passes the remaining arguments on. The add_todo, list_todos, and mark_done functions live in a separate todo.py file that you write in this step.
import sysfrom todo import add_todo, list_todos, mark_donedef main(): if len(sys.argv) < 2: sys.exit("usage: todo <add|list|done> [args]") match sys.argv[1]: case "add": add_todo(sys.argv[2:]) case "list": list_todos() case "done": mark_done(sys.argv[2:]) case other: sys.exit(f"unknown command: {other}")if __name__ == "__main__": main()