88import click
99from os .path import abspath , dirname , exists , isdir , join
1010from functools import wraps
11+ from typing import Optional
1112
1213from rsconnect .certificates import read_certificate_file
1314
6566from .log import logger , LogOutputFormat
6667from .metadata import ServerStore , AppStore
6768from .models import (
69+ AppMode ,
6870 AppModes ,
6971 BuildStatus ,
7072 ContentGuidWithBundleParamType ,
@@ -1254,18 +1256,22 @@ def deploy_html(
12541256 )
12551257
12561258
1257- def generate_deploy_python (app_mode , alias , min_version ):
1259+ def generate_deploy_python (app_mode : AppMode , alias : str , min_version : str , desc : Optional [str ] = None ):
1260+
1261+ if desc is None :
1262+ desc = app_mode .desc ()
1263+
12581264 # noinspection SpellCheckingInspection
12591265 @deploy .command (
12601266 name = alias ,
12611267 short_help = "Deploy a {desc} to Posit Connect [v{version}+], Posit Cloud, or shinyapps.io." .format (
1262- desc = app_mode . desc () ,
1268+ desc = desc ,
12631269 version = min_version ,
12641270 ),
12651271 help = (
12661272 "Deploy a {desc} module to Posit Connect, Posit Cloud, or shinyapps.io (if supported by the platform). "
12671273 'The "directory" argument must refer to an existing directory that contains the application code.'
1268- ).format (desc = app_mode . desc () ),
1274+ ).format (desc = desc ),
12691275 no_args_is_help = True ,
12701276 )
12711277 @server_args
@@ -1277,7 +1283,7 @@ def generate_deploy_python(app_mode, alias, min_version):
12771283 "-e" ,
12781284 help = (
12791285 "The module and executable object which serves as the entry point for the {desc} (defaults to app)"
1280- ).format (desc = app_mode . desc () ),
1286+ ).format (desc = desc ),
12811287 )
12821288 @click .option (
12831289 "--exclude" ,
@@ -1372,14 +1378,13 @@ def deploy_app(
13721378 return deploy_app
13731379
13741380
1375- deploy_api = generate_deploy_python (app_mode = AppModes .PYTHON_API , alias = "api" , min_version = "1.8.2" )
1376- # TODO: set fastapi min_version correctly
1377- # deploy_fastapi = generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0")
1378- deploy_fastapi = generate_deploy_python (app_mode = AppModes .PYTHON_FASTAPI , alias = "fastapi" , min_version = "2021.08.0" )
1379- deploy_dash_app = generate_deploy_python (app_mode = AppModes .DASH_APP , alias = "dash" , min_version = "1.8.2" )
1380- deploy_streamlit_app = generate_deploy_python (app_mode = AppModes .STREAMLIT_APP , alias = "streamlit" , min_version = "1.8.4" )
1381- deploy_bokeh_app = generate_deploy_python (app_mode = AppModes .BOKEH_APP , alias = "bokeh" , min_version = "1.8.4" )
1382- deploy_shiny = generate_deploy_python (app_mode = AppModes .PYTHON_SHINY , alias = "shiny" , min_version = "2022.07.0" )
1381+ generate_deploy_python (app_mode = AppModes .PYTHON_API , alias = "api" , min_version = "1.8.2" )
1382+ generate_deploy_python (app_mode = AppModes .PYTHON_API , alias = "flask" , min_version = "1.8.2" , desc = "Flask API" )
1383+ generate_deploy_python (app_mode = AppModes .PYTHON_FASTAPI , alias = "fastapi" , min_version = "2021.08.0" )
1384+ generate_deploy_python (app_mode = AppModes .DASH_APP , alias = "dash" , min_version = "1.8.2" )
1385+ generate_deploy_python (app_mode = AppModes .STREAMLIT_APP , alias = "streamlit" , min_version = "1.8.4" )
1386+ generate_deploy_python (app_mode = AppModes .BOKEH_APP , alias = "bokeh" , min_version = "1.8.4" )
1387+ generate_deploy_python (app_mode = AppModes .PYTHON_SHINY , alias = "shiny" , min_version = "2022.07.0" )
13831388
13841389
13851390@deploy .command (
@@ -1711,24 +1716,27 @@ def write_manifest_quarto(
17111716 )
17121717
17131718
1714- def generate_write_manifest_python (app_mode , alias ):
1719+ def generate_write_manifest_python (app_mode , alias , desc : Optional [str ] = None ):
1720+ if desc is None :
1721+ desc = app_mode .desc ()
1722+
17151723 # noinspection SpellCheckingInspection
17161724 @write_manifest .command (
17171725 name = alias ,
1718- short_help = "Create a manifest.json file for a {desc}." .format (desc = app_mode . desc () ),
1726+ short_help = "Create a manifest.json file for a {desc}." .format (desc = desc ),
17191727 help = (
17201728 "Create a manifest.json file for a {desc} for later deployment. This will create an "
17211729 'environment file ("requirements.txt") if one does not exist. All files '
17221730 "are created in the same directory as the API code."
1723- ).format (desc = app_mode . desc () ),
1731+ ).format (desc = desc ),
17241732 )
17251733 @click .option ("--overwrite" , "-o" , is_flag = True , help = "Overwrite manifest.json, if it exists." )
17261734 @click .option (
17271735 "--entrypoint" ,
17281736 "-e" ,
17291737 help = (
17301738 "The module and executable object which serves as the entry point for the {desc} (defaults to app)"
1731- ).format (desc = app_mode . desc () ),
1739+ ).format (desc = desc ),
17321740 )
17331741 @click .option (
17341742 "--exclude" ,
@@ -1793,12 +1801,13 @@ def manifest_writer(
17931801 return manifest_writer
17941802
17951803
1796- write_manifest_api = generate_write_manifest_python (AppModes .PYTHON_API , alias = "api" )
1797- write_manifest_fastapi = generate_write_manifest_python (AppModes .PYTHON_FASTAPI , alias = "fastapi" )
1798- write_manifest_dash = generate_write_manifest_python (AppModes .DASH_APP , alias = "dash" )
1799- write_manifest_streamlit = generate_write_manifest_python (AppModes .STREAMLIT_APP , alias = "streamlit" )
1800- write_manifest_bokeh = generate_write_manifest_python (AppModes .BOKEH_APP , alias = "bokeh" )
1801- write_manifest_shiny = generate_write_manifest_python (AppModes .PYTHON_SHINY , alias = "shiny" )
1804+ generate_write_manifest_python (AppModes .BOKEH_APP , alias = "bokeh" )
1805+ generate_write_manifest_python (AppModes .DASH_APP , alias = "dash" )
1806+ generate_write_manifest_python (AppModes .PYTHON_API , alias = "api" )
1807+ generate_write_manifest_python (AppModes .PYTHON_API , alias = "flask" , desc = "Flask API" )
1808+ generate_write_manifest_python (AppModes .PYTHON_FASTAPI , alias = "fastapi" )
1809+ generate_write_manifest_python (AppModes .PYTHON_SHINY , alias = "shiny" )
1810+ generate_write_manifest_python (AppModes .STREAMLIT_APP , alias = "streamlit" )
18021811
18031812
18041813# noinspection SpellCheckingInspection
0 commit comments