@classmethod
def dispatch(cls, arguments, **kwargs):
    """Dispatch arguments parsed by docopt to the cmd with matching spec.

        :param arguments:
        :param kwargs:
        :return: exit_code
        """
    for spec, func in cls._specs:
        args = []
        options = list(filter(lambda k: k.startswith('-') and (arguments[k] or
            k in spec), arguments.keys()))
        cmds = list(filter(lambda k: not (k.startswith('-') or k.startswith
            ('<')) and arguments[k], arguments.keys()))
        args_spec = list(filter(lambda k: k.startswith('<'), spec))
        cmd_spec = list(filter(lambda k: not (k.startswith('-') or k.
            startswith('<')), spec))
        for element in spec:
            if element.startswith('-'):
                if element in options:
                    args.append(arguments.get(element, False))
                    options.remove(element)
            elif element.startswith('<') and not arguments.get(element
                ) is False:
                args.append(arguments.get(element))
                if element in args_spec:
                    args_spec.remove(element)
            elif element in cmds and element in cmd_spec:
                cmds.remove(element)
                cmd_spec.remove(element)
        if options:
            continue
        if cmds:
            continue
        if args_spec:
            continue
        if cmd_spec:
            continue
        exit_code = func(*args, **kwargs)
        return exit_code
    raise Exception('No implementation for spec: %s' % arguments)
