summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jfr_playoff/settings.py6
-rw-r--r--playoff.py23
2 files changed, 24 insertions, 5 deletions
diff --git a/jfr_playoff/settings.py b/jfr_playoff/settings.py
index 9d727a7..021253f 100644
--- a/jfr_playoff/settings.py
+++ b/jfr_playoff/settings.py
@@ -11,12 +11,12 @@ def complete_filename(text, state):
class PlayoffSettings(object):
- def __init__(self):
+ def __init__(self, config_file):
self.settings = None
self.interactive = False
self.settings_file = None
- if len(sys.argv) > 1:
- self.settings_file = sys.argv[1].decode(
+ if config_file is not None:
+ self.settings_file = config_file.decode(
sys.getfilesystemencoding())
else:
self.interactive = True
diff --git a/playoff.py b/playoff.py
index c335b55..a88d151 100644
--- a/playoff.py
+++ b/playoff.py
@@ -7,8 +7,24 @@ from jfr_playoff.settings import PlayoffSettings
def main():
+ interactive = False
+
try:
- settings = PlayoffSettings()
+ import argparse
+ arg_parser = argparse.ArgumentParser(
+ description='Generate play-off HTML for JFR Teamy tournaments')
+ output_args = arg_parser.add_mutually_exclusive_group()
+ output_args.add_argument('-v', '--verbose', action='store_true',
+ help='display debug info on STDERR')
+ output_args.add_argument('-q', '--quiet', action='store_true',
+ help='suppress warnings on STDERR')
+ arg_parser.add_argument('config_file', metavar='JSON_FILE',
+ help='path to config JSON file',
+ type=str, nargs='?', default=None)
+ arguments = arg_parser.parse_args()
+
+ settings = PlayoffSettings(arguments.config_file)
+ interactive = settings.interactive
generator = PlayoffGenerator(settings)
content = generator.generate_content()
@@ -17,10 +33,13 @@ def main():
file_manager.write_content(content)
file_manager.copy_scripts()
file_manager.send_files()
+ except SystemExit:
+ interactive = False
+ raise
except:
print traceback.format_exc()
finally:
- if settings.interactive:
+ if interactive:
raw_input('Press any key to continue...')
if __name__ == '__main__':