#!/usr/bin/env python3

import appdirs, argparse

try:
    from tradfricoap.config import get_config, host_config,ConfigNotFoundError
    from tradfricoap import ApiNotFoundError

    CONFIGFILE = "{0}/gateway.json".format(appdirs.user_config_dir(appname="tradfri"))
    CONF = get_config(CONFIGFILE).configuation
    
    if CONF["Api"] == "Coapcmd":
        from tradfricoap.coapcmd_api import set_coapcmd

        set_coapcmd(
            "coapcmd"
        )

except ImportError:
    _globalError = "Module 'tradfricoap' not found"

# from tradfri.config import host_config


import tradfricoap.cli as cli


if __name__ == "__main__":
    #subargs = cli.default_parsers_args()

    # subargs.add_parser("version")
    # args = cli.get_args()

    try:
        cli.process_args()
    except ApiNotFoundError as e:
        print("Error: {}".format(e.message))

    #if args.command == "version":
    #    print("overrided version")
    #else:
    #    cli.process_args(args)   

    
