todo
todo copied to clipboard
Add export command to dump tasks in csv/json/md
Description
This pull request introduces a new export command that allows users to dump their task list in three popular formats—CSV, JSON, or Markdown—either to standard output or to a file. This makes it easy to share, archive, or further process your to-do data in other tools.
Changes
-
CLI parser (
cli_parser.py)- Added an
exportsubcommand with two options:-
-f, --format(csv⎼ default,json, ormd) -
-o, --output(path to write output; if omitted, writes to stdout)
-
- Registered
exportin theCOMMANDSset.
- Added an
-
Command handler (
todo.py)- Imported the standard
csvandjsonmodules. - Implemented
export_tasks(args, daccess), which:- Loads all tasks (including subcontexts) via
daccess.todo(path='', recursive=True). - Opens either the specified output file (UTF-8, newline-safe) or uses
sys.stdout. - For CSV, writes a header row (
ID, Title, Context, Deadline, Start, Period, Priority, Status) and one row per task. - For JSON, dumps the full task list with pretty-printing (
indent=2). - For Markdown, emits a GitHub-style table with the same columns.
- Loads all tasks (including subcontexts) via
- Closes the file handle if an output path was provided.
- Registered
export_tasksunder'export'in theDISPATCHERmap.
- Imported the standard
Usage Examples
# Export to CSV (default) on the terminal:
todo export
# Export to Markdown and save to tasks.md:
todo export -f md -o tasks.md
# Export to JSON and save to all_tasks.json:
todo export -f json -o all_tasks.json