def main(argv=None):
    import lymph.monkey
    lymph.monkey.patch()

    import docopt
    import sys
    import logging

    from lymph import __version__ as VERSION
    from lymph.cli.help import HELP
    from lymph.cli.base import get_command_class
    from lymph.utils import logging as lymph_logging

    bootup_handler = logging.StreamHandler()
    logging.getLogger().addHandler(bootup_handler)

    args = docopt.docopt(HELP, argv, version=VERSION, options_first=True)
    name = args.pop('<command>')
    argv = args.pop('<args>')
    try:
        command_cls = get_command_class(name)
    except __HOLE__:
        print("'%s' is not a valid lymph command. See 'lymph list' or 'lymph help'." % name)
        return 1
    command_args = docopt.docopt(command_cls.get_help(), [name] + argv)
    args.update(command_args)

    config = setup_config(args) if command_cls.needs_config else None

    logging.getLogger().removeHandler(bootup_handler)
    if config:
        loglevel = args.get('--loglevel', 'ERROR')
        logfile = args.get('--logfile')

        lymph_logging.setup_logging(config, loglevel, logfile)
    else:
        logging.basicConfig()

    sys.excepthook = _excepthook

    terminal = setup_terminal(args, config)
    command = command_cls(args, config, terminal)
    return command.run()
dataset/ETHPy150Open deliveryhero/lymph/lymph/cli/main.py/main