from argparse import ArgumentParser
from util import gettemp, datevalid
import pandas as p


def main():
    parser = ArgumentParser(description='Download kwh data from dataframe')
    parser.add_argument("-o", "--output", dest="output",     help = "output pickle path", metavar="PATH", required = True)
    parser.add_argument("-s", "--start-date", dest = "startdate", help = "start date for download; format: YYYY-MM-DD; default: 2016-04-01", metavar="DATE", default = "2016-04-01", type = datevalid)
    parser.add_argument("-e", "--end-date", dest = "enddate", help = "end date for download; format: YYYY-MM-DD; default: 2019-01-01", metavar="DATE", default = "2019-01-01", type = datevalid)
    parser.add_argument("--station", dest = "station", help = "weather station to get data from; default: 2006", metavar="STATION", default = "2006")
    parser.add_argument("-v", "--verbose", dest = "verbose", action ="store_true")
    args = parser.parse_args()
    tempdata = gettemp(args.startdate.strftime("%Y-%m-%d"), args.enddate.strftime("%Y-%m-%d"), args.station, args.verbose)
    tempdata.to_pickle(args.output)

if __name__ == "__main__":
    main()
