'Execute the command'

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

    try:
        course_key = CourseKey.from_string(options['course_key'])
    except InvalidKeyError:
        raise CommandError('Invalid    course    key.')
    if (not modulestore().get_course(course_key)):
        raise CommandError('Course    not    found.')
    owning_store = modulestore()._get_modulestore_for_courselike(course_key)
    if hasattr(owning_store, 'force_publish_course'):
        versions = get_course_versions(options['course_key'])
        print 'Course    versions    :    {0}'.format(versions)
        if options['commit']:
            if query_yes_no('Are    you    sure    to    publish    the    {0}    course    forcefully?'.format(course_key), default='no'):
                updated_versions = owning_store.force_publish_course(course_key, ModuleStoreEnum.UserID.mgmt_command, options['commit'])
                if updated_versions:
                    if (versions['published-branch'] != versions['draft-branch']):
                        print "Success!    Published    the    course    '{0}'    forcefully.".format(course_key)
                        print 'Updated    course    versions    :    \n{0}'.format(updated_versions)
                    else:
                        print "Course    '{0}'    is    already    in    published    state.".format(course_key)
                else:
                    print 'Error!    Could    not    publish    course    {0}.'.format(course_key)
        elif (versions['published-branch'] != versions['draft-branch']):
            print 'Dry    run.    Following    would    have    been    changed    :    '
            print 'Published    branch    version    {0}    changed    to    draft    branch    version    {1}'.format(versions['published-branch'], versions['draft-branch'])
        else:
            print "Dry    run.    Course    '{0}'    is    already    in    published    state.".format(course_key)
    else:
        raise CommandError('The    owning    modulestore    does    not    support    this    command.')
