#!/usr/bin/env python3
import argparse, sys
from folioCronService import cronOkapiService, cronOkapiServiceSetup,cronConfig

parser = argparse.ArgumentParser(description='Setup or run service')
subparsers = parser.add_subparsers()
parser_cronokapiservice = subparsers.add_parser('service', help='runs okapi api')
parser_cronokapiservice.set_defaults(func=cronOkapiService) 
parser_cronokapiservice.add_argument('--configDir',type = str,help='Directory with folioCronService configs, default to system directory')
parser_cronokapiservice.add_argument('name', type = str)
parser_cronokapiservicesetup = subparsers.add_parser('setup', help='Set up crontab to run tasks in config folder')
parser_cronokapiservicesetup.set_defaults(func=cronOkapiServiceSetup)
parser_cronokapiservicesetup.add_argument('--configDir',type = str,help='Directory with folioCronService configs, default to system directory')
parser_cronconfig = subparsers.add_parser('config', help='set up credentials')
parser_cronconfig.set_defaults(func=cronConfig) 
parser_cronconfig.add_argument('username', type = str)
parser_cronconfig.add_argument('password', type = str)
if len(sys.argv)>1:
    options = parser.parse_args()
    options.func(**vars(options))
else:
    parser.print_help()
