def do_cli(ctx, template, semantic_version):
try:<EOL><INDENT>template_data = get_template_data(template)<EOL><DEDENT>except ValueError as ex:<EOL><INDENT>click.secho("<STR_LIT>", fg='<STR_LIT>')<EOL>raise UserException(str(ex))<EOL><DEDENT>if semantic_version and SERVERLESS_REPO_APPLICATION in template_data.get(METADATA, {}):<EOL><INDENT>template_data.get(METADATA).get(SERVERLESS_REPO_APPLICATION)[SEMANTIC_VERSION] = semantic_version<EOL><DEDENT>try:<EOL><INDENT>publish_output = publish_application(template_data)<EOL>click.secho("<STR_LIT>", fg="<STR_LIT>")<EOL>click.secho(_gen_success_message(publish_output))<EOL><DEDENT>except InvalidS3UriError:<EOL><INDENT>click.secho("<STR_LIT>", fg='<STR_LIT>')<EOL>raise UserException(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(SAM_PACKAGE_DOC))<EOL><DEDENT>except ServerlessRepoError as ex:<EOL><INDENT>click.secho("<STR_LIT>", fg='<STR_LIT>')<EOL>LOG.debug("<STR_LIT>", exc_info=True)<EOL>error_msg = '<STR_LIT>'.format(str(ex), SAM_PUBLISH_DOC)<EOL>raise UserException(error_msg)<EOL><DEDENT>application_id = publish_output.get('<STR_LIT>')<EOL>_print_console_link(ctx.region, application_id)<EOL>
Publish the application based on command line inputs.