summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quick_lineup.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/quick_lineup.py b/quick_lineup.py
index 965922e..7da857f 100644
--- a/quick_lineup.py
+++ b/quick_lineup.py
@@ -1,21 +1,24 @@
+import argparse
import sys
from ql.console import Console
def main():
- if len(sys.argv) < 3 or len(sys.argv) > 4:
- print('Give correct parameters: round, segment and (optionally) table')
- sys.exit(1)
+ parser = argparse.ArgumentParser(
+ description='Interface for line-up management in JFR Teamy')
- round = int(sys.argv[1])
- segment = int(sys.argv[2])
- if len(sys.argv) == 4:
- table = int(sys.argv[3])
- else:
- table = None
+ parser.add_argument('round', metavar='ROUND', type=int,
+ help='round number')
+ parser.add_argument('segment', metavar='SEGMENT', type=int,
+ help='segment number')
+ parser.add_argument('table', metavar='TABLE', type=int,
+ nargs='?', default=None,
+ help='table to start from')
+
+ arguments = parser.parse_args()
try:
- Console(round, segment, table).run()
+ Console(arguments.round, arguments.segment, arguments.table).run()
except:
print('ERROR: %s' % sys.exc_info()[1])