'By convention set by Django developers, this method actually executes command\'s actions.
So, there could be no better docstring than emphasize this once again.'

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

    all_option = options.get('all', False)
    setup_option = options.get('setup', False)
    index_all_courses_option = (all_option or setup_option)
    if ((len(args) == 0) and (not index_all_courses_option)):
        raise CommandError(u'reindex_course    requires    one    or    more    arguments:    <course_id>')
    store = modulestore()
    if index_all_courses_option:
        index_name = CoursewareSearchIndexer.INDEX_NAME
        doc_type = CoursewareSearchIndexer.DOCUMENT_TYPE
        if setup_option:
            try:
                searcher = SearchEngine.get_search_engine(index_name)
            except exceptions.ElasticsearchException as exc:
                logging.exception('Search    Engine    error    -    %s', unicode(exc))
                return
            index_exists = searcher._es.indices.exists(index=index_name)
            doc_type_exists = searcher._es.indices.exists_type(index=index_name, doc_type=doc_type)
            index_mapping = (searcher._es.indices.get_mapping(index=index_name, doc_type=doc_type) if (index_exists and doc_type_exists) else {})
            if (index_exists and index_mapping):
                return
        if (setup_option or query_yes_no(self.CONFIRMATION_PROMPT, default='no')):
            course_keys = [course.id for course in modulestore().get_courses()]
        else:
            return
    else:
        course_keys = map(self._parse_course_key, args)
    for course_key in course_keys:
        CoursewareSearchIndexer.do_course_reindex(store, course_key)
