#!/usr/bin/python3

from sys import path
import os, argparse

MAINFOLDER = "/usr/share/connector"
path.append(MAINFOLDER)
pwd = os.getcwd() + '/'
os.chdir (MAINFOLDER)
from GLOBAL import (VERSION, RELEASE)

def parseArgs():
    """Description of the command line argument parser"""
    about = "Connector - %s (%s)" % (VERSION, RELEASE)
    args = argparse.ArgumentParser(prog = 'connector', formatter_class=argparse.RawTextHelpFormatter,
                                   description = 'Connector - remote desktop chooser.\n\nDo not specify parameters for starting the GUI.')
    args.add_argument ('-v', '--version', action = 'version', help = "show the application version", version = about)
    args.add_argument ('-d', '--debug', action = 'store_true', default = False, help = "show log files online")
    args.add_argument ('-q', '--quit', action = 'store_true', default = False, help = "quit the application")
    args.add_argument('name', type = str, nargs = '?', help = 'name of the file (.ctor, .remmina, .rdp) or saved connection')
    return args.parse_args()

if __name__ == '__main__':
    os.system("xdg-mime default connector.desktop application/x-connector")
    args = parseArgs()
    from gui import quitApp as quit
    if args.quit: quit()
    from gui import startDebug as debug
    if args.debug: debug()
    from gui import f_main as run
    run (pwd, args.name)
