Add option for taskwarrior overrides
This commit is contained in:
parent
e548fa6edb
commit
30c6aea11b
2 changed files with 14 additions and 9 deletions
|
@ -9,7 +9,7 @@ import re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import options
|
import options as opts
|
||||||
|
|
||||||
|
|
||||||
def get_todo_block_date(line, todo_block_title):
|
def get_todo_block_date(line, todo_block_title):
|
||||||
|
@ -58,7 +58,7 @@ def handle_completed_tasks(line, date, options):
|
||||||
line,
|
line,
|
||||||
)
|
)
|
||||||
if completed_task and options.taskwarrior_log_completed:
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -77,9 +77,8 @@ def get_prio_string(task_string):
|
||||||
return prio_string
|
return prio_string
|
||||||
|
|
||||||
|
|
||||||
def log_completed_to_taskwarrior(task_string, date, dryrun):
|
def log_completed_to_taskwarrior(task_string, date, options):
|
||||||
overrides = ["rc.context=none", "rc.verbose=nothing", "rc.hooks=0"]
|
overrides = options.taskwarrior_overrides
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"task",
|
"task",
|
||||||
*overrides,
|
*overrides,
|
||||||
|
@ -89,11 +88,9 @@ def log_completed_to_taskwarrior(task_string, date, dryrun):
|
||||||
f"end:{date}",
|
f"end:{date}",
|
||||||
get_prio_string(task_string),
|
get_prio_string(task_string),
|
||||||
]
|
]
|
||||||
|
if options.dryrun:
|
||||||
if dryrun:
|
|
||||||
print(cmd)
|
print(cmd)
|
||||||
return
|
return
|
||||||
|
|
||||||
subprocess.Popen(cmd)
|
subprocess.Popen(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,5 +112,5 @@ def delete_logged_tasks_from_file(fname, lines, dryrun):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
process_file(options.init())
|
process_file(opts.init())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -5,10 +5,18 @@ from dataclasses import dataclass
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Options:
|
class Options:
|
||||||
|
# can be changed
|
||||||
jrnl_fname: str = f"{os.path.expanduser('~')}/documents/records/todo.md"
|
jrnl_fname: str = f"{os.path.expanduser('~')}/documents/records/todo.md"
|
||||||
todo_block_title: str = "todotxt"
|
todo_block_title: str = "todotxt"
|
||||||
dryrun: bool = False
|
dryrun: bool = False
|
||||||
taskwarrior_log_completed: bool = True
|
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_completed: str = r"(?:x|[x])"
|
||||||
regex_task_incomplete: str = r"[ ]"
|
regex_task_incomplete: str = r"[ ]"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue