Example #1
0
File: main.py Project: adrpar/lymph
def main(argv=None):
    import lymph.monkey
    lymph.monkey.patch()

    import docopt

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

    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 KeyError:
        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

    setup_logging(args, config)
    if config:
        config.set('container.log_endpoint', zmqpub_log_handler.endpoint)
    terminal = setup_terminal(args, config)
    command = command_cls(args, config, terminal)
    return command.run()
Example #2
0
def main(argv=None):
    import lymph.monkey
    lymph.monkey.patch()

    import docopt

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

    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 KeyError:
        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

    setup_logging(args, config)
    if config:
        config.set('container.log_endpoint', zmqpub_log_handler.endpoint)
    terminal = setup_terminal(args, config)
    command = command_cls(args, config, terminal)
    return command.run()
Example #3
0
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 KeyError:
        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()
Example #4
0
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 KeyError:
        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()
Example #5
0
 def run(self):
     name = self.args['<command>']
     if name:
         print(get_command_class(name).get_help())
     else:
         print(self.description)
Example #6
0
 def run(self):
     name = self.args['<command>']
     if name:
         print(get_command_class(name).get_help())
     else:
         print(HELP)