Refactor options

This commit is contained in:
Marty Oehme 2021-11-01 12:00:48 +01:00
parent c6cb3dd6c3
commit ec5ff47449
Signed by: Marty
GPG key ID: B7538B8F50A1C800

View file

@ -30,7 +30,10 @@ class Options:
def init(): def init():
opt = Options() opt = Options()
parse_cmdline_args(opt)
parser = argparse.ArgumentParser()
create_cmdline_args(parser)
parse_cmdline_args(parser, opt)
if opt.dryrun: if opt.dryrun:
dryrun_show_options(opt) dryrun_show_options(opt)
return opt return opt
@ -40,8 +43,7 @@ def dryrun_show_options(options):
print(options) print(options)
def parse_cmdline_args(options): def create_cmdline_args(parser):
parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
"-n", "--dryrun", help="only simulate and print changes", action="store_true" "-n", "--dryrun", help="only simulate and print changes", action="store_true"
) )
@ -71,6 +73,9 @@ def parse_cmdline_args(options):
help="don't add ideas as maybe items to taskwarrior", help="don't add ideas as maybe items to taskwarrior",
action="store_true", action="store_true",
) )
def parse_cmdline_args(parser, options):
args = parser.parse_args() args = parser.parse_args()
if args.dryrun: if args.dryrun: