Add boxed completion regex

Added recognition of `[x] my task done` to task logging.
This commit is contained in:
Marty Oehme 2021-10-31 16:46:28 +01:00
parent 46a07b1e48
commit 7fdf83f3fe
Signed by: Marty
GPG Key ID: B7538B8F50A1C800
3 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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 = [

View File

@ -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():