import os
import sys
from logging import DEBUG, INFO

from cfg_checker.cli.command import execute_command, helps, parsers
from cfg_checker.common import config, logger, logger_cli
from cfg_checker.helpers.args_utils import MyParser

pkg_dir = os.path.dirname(__file__)
pkg_dir = os.path.normpath(pkg_dir)


def config_check_entrypoint():
    """
    Main entry point. Uses nested parsers structure
    with a default function to execute the comand

    :return: - no return value
    """
    # Main entrypoint
    parser = MyParser(prog="# Mirantis Cloud configuration checker")

    parser.add_argument(
        "-d",
        "--debug",
        action="store_true", default=False,
        help="Set CLI logging level to DEBUG"
    )
    parser.add_argument(
        '-s',
        '--sudo',
        action='store_true', default=True,
        help="Use sudo for getting salt creds"
    )
    subparsers = parser.add_subparsers(dest='command')

    # create parsers
    for _command in helps.keys():
        _parser = subparsers.add_parser(
            _command,
            help=helps[_command]
        )
        parsers[_command](_parser)

    # parse arguments
    try:
        args, unknown = parser.parse_known_args()
    except TypeError:
        logger_cli.info("\n# Please, check arguments")
        sys.exit(0)

    if unknown:
        logger_cli.error(
            "# Unexpected arguments: {}".format(
                ", ".join(["'{}'".format(a) for a in unknown])
            )
        )
        sys.exit(1)

    # Pass externally configured values
    config.ssh_uses_sudo = args.sudo

    # Handle options
    if args.debug:
        logger_cli.setLevel(DEBUG)
    else:
        logger_cli.setLevel(INFO)

    # Execute the command
    result = execute_command(args, args.command)
    logger.debug(result)
    sys.exit(result)


if __name__ == '__main__':
    config_check_entrypoint()
