def check_arguments(argspec, args):
    """Validates there is the right number of arguments"""
    if not argspec.varargs and not argspec.args and args:
        raise TypeError('command does not take varargs')
    if not argspec.varargs and argspec.args and len(args) != len(argspec.args):
        raise TypeError('command takes {} arguments: {} passed'.format(len(
            argspec.args), len(args)))
