#!/usr/bin/env python3

import sys, getopt

import pyMadness

def main(argv):
    first = ""
    second = ""
    verbose = False
    neutral = False
    test = False
    try:
        opts, args = getopt.getopt(argv, "hf:s:vnt", ["help", "first=", "second=", "verbose", "neutral","test"])
    except getopt.GetoptError as err:
        print(err)
        usage()
        sys.exit(2)
    output = None
    verbose = False
    for o, a in opts:
        if o in ("-v", "--verbose"):
            verbose = True
        elif o in ("-n", "--neutral"):
            neutral = True
        elif o in ("-t", "--test"):
            test = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit
        elif o in ("-f", "--first"):
            first = a
        elif o in ("-s", "--second"):
            second = a
        else:
            assert False, "unhandled option"
    print ("Score Matchup Tool")
    print ("**************************")
    usage()
    print ("**************************")
    if (test):
        testResult = pyMadness.Test(verbose)
        if (testResult):
            print ("Test result - pass")
        else:
            print ("Test result - fail")
    else:
        if (not first and not second):
            print ("you must input the team names to run this tool, (first and second arguments)")
            exit()
        dict_score = {}
        dict_score = pyMadness.Calculate(first, second, neutral, verbose)

def usage():
    usage = """
    -h --help                 Prints this
    -v --verbose              Increases the information level
    -f --first                First Team (The Away Team)
    -s --second               Second Team (The Home Team)
    -n --neutral              Playing on a neutral Field
    -t --test                 runs test routine to check calculations
    """
    print (usage) 

if __name__ == "__main__":
  main(sys.argv[1:])

@@ -40,24 +40,316 @@
 opt%0A
-%0Aimport pyMadnes
+import os.path%0Afrom datetime import datetime%0A%0Aimport pyMadness%0A%0Adef CurrentStatsFile(filename):%0A    stat = os.path.getmtime(filename)%0A    stat_date = datetime.fromtimestamp(stat)%0A    if stat_date.date() %3C datetime.now().date():%0A        return False%0A    return True%0A%0Adef RefreshStats():%0A    import scrape_stat
 s%0A%0Ad
@@ -1242,24 +1242,46 @@
 *********%22)%0A
+    if (verbose):%0A    
     usage()%0A
@@ -1276,24 +1276,28 @@
     usage()%0A
+    
     print (%22
@@ -1681,26 +1681,114 @@
         
-dict_score
+file = %22stats.json%22%0A        if (not CurrentStatsFile(file)):%0A            RefreshStats()%0A        ds
  = %7B%7D%0A  
@@ -1798,17 +1798,9 @@
    d
-ict_score
+s
  = p
@@ -1850,16 +1850,364 @@
 verbose)
+%0A        if (neutral):%0A            print (%22%7B0%7D %7B1%7D vs %7B2%7D %7B3%7D %7B4%7D-%7B5%7D%22.format(ds%5B%22teama%22%5D, ds%5B%22chancea%22%5D, ds%5B%22teamb%22%5D, ds%5B%22chanceb%22%5D,%0A                ds%5B%22scorea%22%5D, ds%5B%22scoreb%22%5D))%0A        else:%0A            print (%22%7B0%7D %7B1%7D at %7B2%7D %7B3%7D %7B4%7D-%7B5%7D%22.format(ds%5B%22teama%22%5D, ds%5B%22chancea%22%5D, ds%5B%22teamb%22%5D, ds%5B%22chanceb%22%5D,%0A                ds%5B%22scorea%22%5D, ds%5B%22scoreb%22%5D))
 %0A%0Adef us

make score matchup tool easier to use