#!/usr/bin/env python3
# This file is part of kytos-utils.
#
# Copyright (c) 2016-2019 by Kytos Team.
#
# Authors:
#    Beraldo Leal <beraldo AT ncc DOT unesp DOT br>

"""kytos - The kytos command line.

Usage: kytos [-c <file>|--config <file>] <command> [<args>...]
       kytos [-v|--version]
       kytos [-h|--help]

Options:
  -c <file>, --config <file>    Load config file [default: ~/.kytosrc]
  -h, --help                    Show this screen.
  -v, --version                 Show version.

The most commonly used kytos commands are:
   napps      Create, list, enable, install (and other actions) NApps.
   server     Start, Stop your Kytos Controller (Kytos)
   users      Commands to handle users from NApps server.
   web        Manage the Web User Interface
   bug-report Display detailed information about the current environment.

See 'kytos <command> -h|--help' for more information on a specific command.
"""
import logging

from docopt import docopt
from kytos.utils.config import KytosConfig

logging.basicConfig(format='%(levelname)-5s %(message)s', level=logging.INFO)

if __name__ == '__main__':
    metadata = KytosConfig().get_metadata()
    version = metadata.get('__version__')

    args = docopt(__doc__,
                  version='kytos command line, version %s' % version,
                  options_first=True)
    command = args['<command>']
    command_args = args['<args>']
    argv = [command] + command_args

    if command == 'napps':
        from kytos.cli.commands.napps.parser import parse

        parse(argv)
    elif command == 'users':
        from kytos.cli.commands.users.parser import parse

        parse(argv)
    elif command == 'web':
        from kytos.cli.commands.web.parser import parse

        parse(argv)
    elif command == 'bug-report':
        from kytos.cli.commands.bug_report.parser import parse

        parse(argv)
    else:
        print("Error: Invalid syntax")
        exit(__doc__)
