import os import argparse from dataclasses import dataclass, field from typing import List @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 taskwarrior_add_incomplete: bool = True taskwarrior_fill_today: bool = True # can not yet be changed 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"\[ \]" def init(): opt = Options() parse_cmdline_args(opt) if opt.dryrun: dryrun_show_options(opt) return opt def dryrun_show_options(options): 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 title of entries to parse") parser.add_argument( "-L", "--nologging", help="don't log done todo items to taskwarrior", action="store_true", ) parser.add_argument( "-I", "--noincomplete", help="don't add incomplete todo items to taskwarrior", action="store_true", ) parser.add_argument( "-T", "--nofilltoday", help="don't add today's todo items as entry to file", action="store_true", ) args = parser.parse_args() if args.dryrun: options.dryrun = True if args.nologging: options.taskwarrior_log_completed = False if args.noincomplete: options.taskwarrior_add_incomplete = False if args.nofilltoday: options.taskwarrior_fill_today = False if args.file: options.jrnl_fname = args.file if args.blocktitle: options.todo_block_title = args.blocktitle return options