'searches for roles on the Ansible Galaxy server'

def execute_search(self):

    page_size = 1000
    search = None
    if len(self.args):
        terms = []
        for i in range(len(self.args)):
            terms.append(self.args.pop())
        search = '+'.join(terms[::(-1)])
    if ((not search) and (not self.options.platforms) and (not self.options.galaxy_tags) and (not self.options.author)):
        raise AnsibleError('Invalid    query.    At    least    one    search    term,    platform,    galaxy    tag    or    author    must    be    provided.')
    response = self.api.search_roles(search, platforms=self.options.platforms, tags=self.options.galaxy_tags, author=self.options.author, page_size=page_size)
    if (response['count'] == 0):
        display.display('No    roles    match    your    search.', color=C.COLOR_ERROR)
        return True
    data = [u'']
    if (response['count'] > page_size):
        data.append((u'Found    %d    roles    matching    your    search.    Showing    first    %s.' % (response['count'], page_size)))
    else:
        data.append((u'Found    %d    roles    matching    your    search:' % response['count']))
    max_len = []
    for role in response['results']:
        max_len.append(len(((role['username'] + '.') + role['name'])))
    name_len = max(max_len)
    format_str = (u'    %%-%ds    %%s' % name_len)
    data.append(u'')
    data.append((format_str % (u'Name', u'Description')))
    data.append((format_str % (u'----', u'-----------')))
    for role in response['results']:
        data.append((format_str % ((u'%s.%s' % (role['username'], role['name'])), role['description'])))
    data = u'\n'.join(data)
    self.pager(data)
    return True
