Add option for taskwarrior overrides

This commit is contained in:
Marty Oehme 2021-10-31 17:06:28 +01:00
parent e548fa6edb
commit 30c6aea11b
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 14 additions and 9 deletions

View file

@ -9,7 +9,7 @@ import re
import os
import sys
import subprocess
import options
import options as opts
def get_todo_block_date(line, todo_block_title):
@ -58,7 +58,7 @@ def handle_completed_tasks(line, date, options):
line,
)
if completed_task and options.taskwarrior_log_completed:
log_completed_to_taskwarrior(completed_task[1], date, options.dryrun)
log_completed_to_taskwarrior(completed_task[1], date, options)
return True
return False
@ -77,9 +77,8 @@ def get_prio_string(task_string):
return prio_string
def log_completed_to_taskwarrior(task_string, date, dryrun):
overrides = ["rc.context=none", "rc.verbose=nothing", "rc.hooks=0"]
def log_completed_to_taskwarrior(task_string, date, options):
overrides = options.taskwarrior_overrides
cmd = [
"task",
*overrides,
@ -89,11 +88,9 @@ def log_completed_to_taskwarrior(task_string, date, dryrun):
f"end:{date}",
get_prio_string(task_string),
]
if dryrun:
if options.dryrun:
print(cmd)
return
subprocess.Popen(cmd)
@ -115,5 +112,5 @@ def delete_logged_tasks_from_file(fname, lines, dryrun):
if __name__ == "__main__":
process_file(options.init())
process_file(opts.init())
sys.exit(0)

View file

@ -5,10 +5,18 @@ from dataclasses import dataclass
@dataclass
class Options:
# can be changed
jrnl_fname: str = f"{os.path.expanduser('~')}/documents/records/todo.md"
todo_block_title: str = "todotxt"
dryrun: bool = False
taskwarrior_log_completed: bool = True
# can not yet be changed
taskwarrior_overrides: list = [
"rc.context=none",
"rc.verbose=nothing",
"rc.hooks=0",
]
regex_task_completed: str = r"(?:x|[x])"
regex_task_incomplete: str = r"[ ]"