#!/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, 'getopt.getopt', 'getopt.getopt', False, 'import getopt\n'), (23, 'time.sleep', 'time.sleep', False, 'import time\n'), (24, 'lib.core.parse.banner.usage', 'banner.usage', False, 'from lib.core.parse import banner\n'), (25, 'sys.exit', 'sys.exit', False, 'import sys\n'), (29, 'lib.core.parse.banner.usage', 'banner.usage', False, 'from lib.core.parse import banner\n'), (30, 'sys.exit', 'sys.exit', False, 'import sys\n'), (34, 'lib.core.util.packages_check', 'util.packages_check', False, 'from lib.core import util\n'), (35, 'lib.core.installer.start_install', 'installer.start_install', False, 'from lib.core import installer\n'), (38, 'sys.exit', 'sys.exit', False, 'import sys\n'), (44, 'lib.core.parse.banner.usage', 'banner.usage', False, 'from lib.core.parse import banner\n'), (45, 'sys.exit', 'sys.exit', False, 'import sys\n'), (64, 'time.sleep', 'time.sleep', False, 'import time\n'), (65, 'lib.core.parse.banner.usage', 'banner.usage', False, 'from lib.core.parse import banner\n'), (66, 'sys.exit', 'sys.exit', False, 'import sys\n')]