2021-10-31 15:20:41 +00:00
|
|
|
import os
|
|
|
|
import argparse
|
2021-10-31 16:25:19 +00:00
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from typing import List
|
2021-10-31 15:20:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Options:
|
2021-10-31 16:06:28 +00:00
|
|
|
# can be changed
|
2021-10-31 15:20:41 +00:00
|
|
|
jrnl_fname: str = f"{os.path.expanduser('~')}/documents/records/todo.md"
|
|
|
|
todo_block_title: str = "todotxt"
|
|
|
|
dryrun: bool = False
|
2021-10-31 15:46:28 +00:00
|
|
|
taskwarrior_log_completed: bool = True
|
2021-10-31 16:25:19 +00:00
|
|
|
taskwarrior_add_incomplete: bool = True
|
2021-10-31 17:44:09 +00:00
|
|
|
taskwarrior_fill_today: bool = True
|
2021-10-31 16:06:28 +00:00
|
|
|
|
|
|
|
# can not yet be changed
|
2021-10-31 16:25:19 +00:00
|
|
|
taskwarrior_overrides: List = field(
|
|
|
|
default_factory=lambda: [
|
|
|
|
"rc.context=none",
|
|
|
|
"rc.verbose=nothing",
|
|
|
|
"rc.hooks=0",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
regex_task_completed: str = r"(?:x|\[x\])"
|
|
|
|
regex_task_incomplete: str = r"\[ \]"
|
2021-10-31 15:20:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
def init():
|
|
|
|
opt = Options()
|
|
|
|
parse_cmdline_args(opt)
|
2021-10-31 16:34:49 +00:00
|
|
|
if opt.dryrun:
|
|
|
|
dryrun_show_options(opt)
|
2021-10-31 15:20:41 +00:00
|
|
|
return opt
|
|
|
|
|
|
|
|
|
2021-10-31 16:25:19 +00:00
|
|
|
def dryrun_show_options(options):
|
2021-10-31 15:20:41 +00:00
|
|
|
print(options)
|
|
|
|
|
|
|
|
|
|
|
|
def parse_cmdline_args(options):
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
|
|
|
"-n", "--dryrun", help="only simulate and print changes", action="store_true"
|
|
|
|
)
|
|
|
|
parser.add_argument("-f", "--file", help="the jrnl file to ingest")
|
|
|
|
parser.add_argument("-b", "--blocktitle", help="the jrnl file to ingest")
|
|
|
|
parser.add_argument(
|
|
|
|
"-L",
|
|
|
|
"--nologging",
|
|
|
|
help="don't log done todo items to taskwarrior",
|
|
|
|
action="store_true",
|
|
|
|
)
|
2021-10-31 16:25:19 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"-I",
|
|
|
|
"--noincomplete",
|
|
|
|
help="don't add incomplete todo items to taskwarrior",
|
|
|
|
action="store_true",
|
|
|
|
)
|
2021-10-31 17:44:09 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"-T",
|
|
|
|
"--nofilltoday",
|
|
|
|
help="don't add today's todo items as entry to file",
|
|
|
|
action="store_true",
|
|
|
|
)
|
2021-10-31 15:20:41 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if args.dryrun:
|
|
|
|
options.dryrun = True
|
|
|
|
if args.nologging:
|
2021-10-31 16:25:19 +00:00
|
|
|
options.taskwarrior_log_completed = False
|
|
|
|
if args.noincomplete:
|
|
|
|
options.taskwarrior_add_incomplete = False
|
2021-10-31 17:44:09 +00:00
|
|
|
if args.nofilltoday:
|
|
|
|
options.taskwarrior_fill_today = False
|
2021-10-31 15:20:41 +00:00
|
|
|
if args.file:
|
|
|
|
options.jrnl_fname = args.file
|
|
|
|
if args.blocktitle:
|
|
|
|
options.todo_block_title = args.blocktitle
|
|
|
|
|
|
|
|
return options
|