'Execute the command.
Arguments:
file_path (str): Path to the output file.
*org_list (unicode): List of organization aliases.
Keyword Arguments:
courses (unicode): Comma-separated list of course keys.  If provided,
include only these courses in the results.
Raises:
CommandError'

def handle(self, *args, **options):

    (file_path, org_list) = self._parse_args(args)
    courses = self._get_courses_for_org(org_list)
    only_courses = options.get('courses')
    if (only_courses is not None):
        only_courses = [CourseKey.from_string(course_key.strip()) for course_key in only_courses.split(',')]
        courses = list((set(courses) & set(only_courses)))
    org_list = list((set(org_list) | set((course.org for course in courses))))
    if (not courses):
        raise CommandError(u'No    courses    found    for    orgs:    {orgs}'.format(orgs=',    '.join(org_list)))
    LOGGER.info(u'Retrieving    data    for    courses:    {courses}'.format(courses=',    '.join([unicode(course) for course in courses])))
    with open(file_path, 'w') as file_handle:
        with self._log_execution_time():
            self._write_email_opt_in_prefs(file_handle, org_list, courses)
    LOGGER.info(u'Output    file:    {file_path}'.format(file_path=file_path))
