Source code for gfinder.commands.opportunities

"""GFINDER CLI `opportunities` command."""

import click
from .docstring import set_docstring

from gfinder.config import Config
from gfinder.datastore import DataStore


@click.command(name='opportunities')
@click.option('--mission-scenario-id', type=click.STRING, help='Mission scenario ID (default: '+Config().default_mission_scenario_id+')')
@click.option('--filter', type=click.STRING, help='Filter by any string contained in opportunity ID.')
def opportunities_cmd(mission_scenario_id, filter):
    """List available opportunities (for a given mission scenario, phase/segment and/or target: not implemented).
    """
    opportunities(mission_scenario_id=mission_scenario_id, filter=filter)


[docs]@set_docstring(opportunities_cmd) def opportunities(mission_scenario_id=None, filter=None): opportunity_ids = DataStore().getOpportunityIDs() click.echo('Available opportunities for all mission scenarios:') for opportunity_id in opportunity_ids: if filter: if filter in opportunity_id: click.echo(' {}'.format(opportunity_id)) else: click.echo(' {}'.format(opportunity_id))