#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# coded by Vikas Kundu https://github.com/vikas-kundu
# -------------------------------------------

import sys
import getopt
import time
import config
from lib.core.parse import banner
from lib.core import util
from lib.core import installer


def options():
    argv = sys.argv[1:]
    try:
        opts, args = getopt.getopt(argv, 'm:t:c:o:n:whi', ['mode','task','country','output','number','wizard','help','install'])
        if((len(sys.argv)==9) or (len(sys.argv)==2)):
            pass
        else:
            print("Error! Some parameter is missing please check!")
            time.sleep(2)
            banner.usage()
            sys.exit()
        
    except getopt.GetoptError as err:
        print(err)
        banner.usage()
        sys.exit(2)

    for (o, a) in opts:
        if(o in('-i','--install')):
            if(util.packages_check()==False):
                installer.start_install()
            else:
                print("Packages already installed!")
                sys.exit()

        elif (o in ('-w', '--wizard')):
            config.wizard=True

        elif o in ('-h','--help'):
            banner.usage()
            sys.exit()

        elif o in ('-m','--mode'):
            config.str_mode=str(a)
            
        elif o in ('-t','--task'):
            config.str_task=str(a)
            
        elif o in ('-c','--country'):
            config.str_country=str(a.lower().strip('"\''))
            
        elif o in ('-o','--output'):
            config.str_output=str(a.strip('"\''))
            
        elif o in ('-n','--number'):
            config.str_number=str(a.strip('"\''))

        else:
            print("Something went wrong with argument parsing!")
            time.sleep(2)
            banner.usage()
            sys.exit()

[((18, 21, 18, 128), 'getopt.getopt', 'getopt.getopt', ({(18, 35, 18, 39): 'argv', (18, 41, 18, 56): '"""m:t:c:o:n:whi"""', (18, 58, 18, 127): "['mode', 'task', 'country', 'output', 'number', 'wizard', 'help', 'install']"}, {}), "(argv, 'm:t:c:o:n:whi', ['mode', 'task', 'country', 'output',\n    'number', 'wizard', 'help', 'install'])", False, 'import getopt\n'), ((23, 12, 23, 25), 'time.sleep', 'time.sleep', ({(23, 23, 23, 24): '(2)'}, {}), '(2)', False, 'import time\n'), ((24, 12, 24, 26), 'lib.core.parse.banner.usage', 'banner.usage', ({}, {}), '()', False, 'from lib.core.parse import banner\n'), ((25, 12, 25, 22), 'sys.exit', 'sys.exit', ({}, {}), '()', False, 'import sys\n'), ((29, 8, 29, 22), 'lib.core.parse.banner.usage', 'banner.usage', ({}, {}), '()', False, 'from lib.core.parse import banner\n'), ((30, 8, 30, 19), 'sys.exit', 'sys.exit', ({(30, 17, 30, 18): '(2)'}, {}), '(2)', False, 'import sys\n'), ((34, 15, 34, 36), 'lib.core.util.packages_check', 'util.packages_check', ({}, {}), '()', False, 'from lib.core import util\n'), ((35, 16, 35, 41), 'lib.core.installer.start_install', 'installer.start_install', ({}, {}), '()', False, 'from lib.core import installer\n'), ((38, 16, 38, 26), 'sys.exit', 'sys.exit', ({}, {}), '()', False, 'import sys\n'), ((44, 12, 44, 26), 'lib.core.parse.banner.usage', 'banner.usage', ({}, {}), '()', False, 'from lib.core.parse import banner\n'), ((45, 12, 45, 22), 'sys.exit', 'sys.exit', ({}, {}), '()', False, 'import sys\n'), ((64, 12, 64, 25), 'time.sleep', 'time.sleep', ({(64, 23, 64, 24): '(2)'}, {}), '(2)', False, 'import time\n'), ((65, 12, 65, 26), 'lib.core.parse.banner.usage', 'banner.usage', ({}, {}), '()', False, 'from lib.core.parse import banner\n'), ((66, 12, 66, 22), 'sys.exit', 'sys.exit', ({}, {}), '()', False, 'import sys\n')]