Refactor options
This commit is contained in:
parent
c6cb3dd6c3
commit
ec5ff47449
1 changed files with 8 additions and 3 deletions
11
options.py
11
options.py
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue