'Return an instantiated mailpile.command object or raise a UsageError.
>>> urlmap._command(\'output\', args=[\'html\'], method=False)
<mailpile.plugins.core.Output...>
>>> urlmap._command(\'bogus\')
Traceback (most recent call last):
UsageError: Unknown command: bogus
>>> urlmap._command(\'message/update\', method=\'GET\')
Traceback (most recent call last):
BadMethodError: Invalid method (GET): message/update
>>> urlmap._command(\'message/update\', method=\'POST\',
...                                   query_data={\'evil\': \'1\'})
Traceback (most recent call last):
BadDataError: Bad variable (evil): message/update
>>> urlmap._command(\'search\', args=[\'html\'],
...                 query_data={\'ui_\': \'1\', \'q[]\': \'foobar\'})
<mailpile.plugins.search.Search...>'

def _command(self, name, args=None, query_data=None, post_data=None, method='GET', async=False):

    try:
        match = [c for c in self._api_commands(method, strict=False) if ((method and (name == c.SYNOPSIS[2])) or ((not method) and (name == c.SYNOPSIS[1])))]
        if (len(match) != 1):
            raise UsageError(('Unknown    command:    %s' % name))
    except ValueError as e:
        raise UsageError(str(e))
    command = match[0]
    if (method and (method not in command.HTTP_CALLABLE)):
        raise BadMethodError(('Invalid    method    (%s):    %s' % (method, name)))
    SPECIAL_VARS = ('csrf', 'arg', 'context')
    if command.HTTP_STRICT_VARS:
        prefixes = (['ui_'] + [vn[:(-1)] for vn in (command.HTTP_QUERY_VARS.keys() + command.HTTP_POST_VARS.keys()) if (vn[(-1):] == '*')])
        copy_q = []
        for var in (query_data or []):
            var = var.replace('[]', '')
            if ((var not in command.HTTP_QUERY_VARS) and (var not in SPECIAL_VARS) and (not [v for v in prefixes if var.startswith(v)])):
                raise BadDataError(('Bad    variable    (%s):    %s' % (var, name)))
            else:
                copy_q.append(var)
        copy_p = []
        for var in (post_data or []):
            var = var.replace('[]', '')
            if ((var not in command.HTTP_QUERY_VARS) and (var not in command.HTTP_POST_VARS) and (var not in SPECIAL_VARS) and (not [v for v in prefixes if var.startswith(v)])):
                raise BadDataError(('Bad    variable    (%s):    %s' % (var, name)))
            else:
                copy_p.append(var)
        copy_vars = [(copy_q, query_data), (copy_p, post_data), (['arg'], query_data)]
    else:
        for var in command.HTTP_BANNED_VARS:
            var = var.replace('[]', '')
            if ((query_data and (var in query_data)) or (post_data and (var in post_data))):
                raise BadDataError(('Bad    variable    (%s):    %s' % (var, name)))
        copy_vars = (((query_data or {}).keys(), query_data), ((post_data or {}).keys(), post_data), (['arg'], query_data))
    data = {'_method': method}
    for (vlist, src) in copy_vars:
        for var in vlist:
            varBB = (var + '[]')
            if (src and ((var in src) or (varBB in src))):
                sdata = (src[var] if (var in src) else src[varBB])
                if isinstance(sdata, cgi.FieldStorage):
                    if hasattr(sdata, 'filename'):
                        data[var] = [_FancyString(sdata.value)]
                        data[var][0].filename = sdata.filename
                    else:
                        data[var] = [sdata.value.decode('utf-8')]
                else:
                    data[var] = [d.decode('utf-8') for d in sdata]
    return command(self.session, name, args, data=data, async=async)
