From 7fdf83f3fe46d8ea86e29fba9394acd3b5d05df6 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 31 Oct 2021 16:46:28 +0100 Subject: [PATCH] Add boxed completion regex Added recognition of `[x] my task done` to task logging. --- README.md | 2 +- open-todo-txt.py | 8 ++++---- options.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5548992..ee757c4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It parses the `jrnl` file and logs accomplished tasks in `taskwarrior`. To accomplish this it borrows a little from the [todo.txt](http://todotxt.org/) syntax --- namely the idea of (A) (B) (C) prioritization and `x task done syntax` -(i.e. starting a line with `x ` means it represents an accomplished task). +(i.e. starting a line with `x ` or `[x] ` means it represents an accomplished task). ## Usage diff --git a/open-todo-txt.py b/open-todo-txt.py index aeb951b..12352b8 100755 --- a/open-todo-txt.py +++ b/open-todo-txt.py @@ -45,9 +45,9 @@ def parse_file(options): if not curdate: continue - completed_task = re.search(r"^x ((?:\([A-D]\))? ?.*)$", line) - if completed_task and options.taskwarrior_log_done: - log_done_to_taskwarrior(completed_task[1], curdate, options.dryrun) + completed_task = re.search(r"^(?:x|[x]) ((?:\([A-D]\))? ?.*)$", line) + if completed_task and options.taskwarrior_log_completed: + log_completed_to_taskwarrior(completed_task[1], curdate, options.dryrun) lines_to_delete.append(line_number) if lines_to_delete: @@ -68,7 +68,7 @@ def get_prio_string(task_string): return prio_string -def log_done_to_taskwarrior(task_string, date, dryrun): +def log_completed_to_taskwarrior(task_string, date, dryrun): overrides = ["rc.context=none", "rc.verbose=nothing", "rc.hooks=0"] cmd = [ diff --git a/options.py b/options.py index edf0755..f8e4389 100644 --- a/options.py +++ b/options.py @@ -8,7 +8,7 @@ class Options: jrnl_fname: str = f"{os.path.expanduser('~')}/documents/records/todo.md" todo_block_title: str = "todotxt" dryrun: bool = False - taskwarrior_log_done: bool = True + taskwarrior_log_completed: bool = True def init():