From 85c44f6a7b22f4ee6ecd81633b0b16b08a9d1d34 Mon Sep 17 00:00:00 2001 From: Jane Garvin Date: Wed, 3 Sep 2025 19:09:44 -0500 Subject: [PATCH] Add notes when printing tasks as Markdown. --- tests/test_things_cli.py | 1 + things_cli/cli.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_things_cli.py b/tests/test_things_cli.py index c0a6341..1204d7f 100644 --- a/tests/test_things_cli.py +++ b/tests/test_things_cli.py @@ -78,6 +78,7 @@ def test_today(self): finally: sys.stdout = old_out self.assertIn("To-Do in Today", new_out.getvalue()) + self.assertIn("\n With\n Notes\n", new_out.getvalue()) def test_csv(self): """Test Next via CSV.""" diff --git a/things_cli/cli.py b/things_cli/cli.py index 756b5cd..8fe5bf4 100755 --- a/things_cli/cli.py +++ b/things_cli/cli.py @@ -205,6 +205,7 @@ def txt_dumps(self, tasks, indentation="", result=""): return result for task in tasks: title = task["title"] + notes = task.get("notes", "") context = ( task.get("project_title", None) or task.get("area_title", None) @@ -214,11 +215,13 @@ def txt_dumps(self, tasks, indentation="", result=""): start = task.get("start_date", None) details = " | ".join(filter(None, [start, context])) result = result + f"{indentation}- {title} ({details})\n" - result = self.txt_dumps(task.get("items", []), indentation + " ", result) + new_indentation = indentation + " " + if notes: + lines = [f"{new_indentation}{ln}\n" for ln in notes.split("\n")] + result += "".join(lines) + result = self.txt_dumps(task.get("items", []), new_indentation, result) task.pop("items", []) - result = self.txt_dumps( - task.get("checklist", []), indentation + " ", result - ) + result = self.txt_dumps(task.get("checklist", []), new_indentation, result) return result