# search-{{ snakeName }}.py - Searches for {{ mixedName }}s
import logging
import sys
from smoacks.cli_util import get_opts, get_session
from {{ app_name }}.{{ mixedName }} import {{ mixedName }}

logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger()

def search():
    opts = get_opts('search_{{ snakeName }}', 'Searches for {{ mixedName }}s in a {{ app_name }}',
                    { 'search_text': 'search_text' })

    session = get_session(opts)
    if not session:
        sys.exit('Invalid username/password.')

    success, resp_list ={{ mixedName }}.search(session, opts.search_text)

    if success:
        for resp in resp_list:
            print('{} - {}'.format(resp.get_ids(), resp.{{ search_field }}))
    else:
        print('Search failed with code {} and message: {}'.format(resp.status_code, resp.text))
