Skip to content

Commit

Permalink
Add ability to use and save options in files (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvoigt authored Apr 7, 2020
1 parent 9c61c73 commit 3f54574
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ reportlab
Pillow
pre-commit
pytest
configargparse
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ aspy.yaml==1.3.0 # via pre-commit
atomicwrites==1.3.0 # via pytest
attrs==19.3.0 # via pytest
cfgv==2.0.1 # via pre-commit
configargparse==1.2
identify==1.4.7 # via pre-commit
importlib-metadata==0.23 # via pluggy, pre-commit, pytest
more-itertools==7.2.0 # via pytest, zipp
Expand Down
17 changes: 14 additions & 3 deletions src/domdiv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import codecs
import json
import sys
import argparse
import configargparse
import copy
import fnmatch
import pkg_resources
Expand Down Expand Up @@ -131,8 +131,8 @@ def add_opt(options, option, value):


def parse_opts(cmdline_args=None):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
parser = configargparse.ArgParser(
formatter_class=configargparse.ArgumentDefaultsHelpFormatter,
description="Generate Dominion Dividers",
epilog="Source can be found at 'https://github.com/sumpfork/dominiontabs'. "
"An online version can be found at 'http://domtabs.sandflea.org/'. ",
Expand Down Expand Up @@ -747,6 +747,17 @@ def parse_opts(cmdline_args=None):
dest="write_json",
help="Write json version of card definitions and extras.",
)
group_special.add_argument(
"-c",
is_config_file=True,
help="Use the specified configuration file to provide options. "
"Command line options override options from this file.",
)
group_special.add_argument(
"-w",
is_write_out_config_file_arg=True,
help="Write out the given options to the specified configuration file.",
)

options = parser.parse_args(args=cmdline_args)
# Need to do these while we have access to the parser
Expand Down

0 comments on commit 3f54574

Please sign in to comment.