Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit inline help to correctly list Cloud and shinyapps.io support #482

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rsconnect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,14 +1285,14 @@ def generate_deploy_python(app_mode, alias, min_version):
# noinspection SpellCheckingInspection
@deploy.command(
name=alias,
short_help="Deploy a {desc} to Posit Connect [v{version}+], Posit Cloud, or shinyapps.io.".format(
short_help="Deploy a {desc} to {deploy_targets}.".format(
desc=app_mode.desc(),
version=min_version,
deploy_targets=app_mode.deploy_targets(min_version),
),
help=(
"Deploy a {desc} module to Posit Connect, Posit Cloud, or shinyapps.io (if supported by the platform). "
"Deploy a {desc} to {deploy_targets}. "
'The "directory" argument must refer to an existing directory that contains the application code.'
).format(desc=app_mode.desc()),
).format(desc=app_mode.desc(), deploy_targets=app_mode.deploy_targets(min_version)),
no_args_is_help=True,
)
@server_args
Expand Down
48 changes: 35 additions & 13 deletions rsconnect/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ class AppMode(object):
Connect
"""

def __init__(self, ordinal, name, text, ext=None):
DEPLOY_TARGET_CONNECT = 1
DEPLOY_TARGET_CLOUD = 2
DEPLOY_TARGET_SHINYAPPSIO = 4

def __init__(self, ordinal, name, text, ext=None, deploy_targets=DEPLOY_TARGET_CONNECT):
self._ordinal = ordinal
self._name = name
self._text = text
self._ext = ext
self._deploy_targets = deploy_targets

def ordinal(self):
return self._ordinal
Expand All @@ -46,6 +51,23 @@ def name(self):
def desc(self):
return self._text

def deploy_targets(self, min_connect_version):
targets = []
if self._deploy_targets & self.DEPLOY_TARGET_CONNECT:
targets.append(f"Posit Connect [v{min_connect_version}+]")
if self._deploy_targets & self.DEPLOY_TARGET_CLOUD:
targets.append("Posit Cloud")
if self._deploy_targets & self.DEPLOY_TARGET_SHINYAPPSIO:
targets.append("shinyapps.io")

if len(targets) > 1:
targets[-1] = "or " + targets[-1]

separator = " "
if len(targets) > 2:
separator = ", "
return separator.join(targets)

def extension(self):
return self._ext

Expand All @@ -63,21 +85,21 @@ class AppModes(object):
"""

UNKNOWN = AppMode(0, "unknown", "<unknown>")
SHINY = AppMode(1, "shiny", "Shiny App", ".R")
RMD = AppMode(3, "rmd-static", "R Markdown", ".Rmd")
SHINY_RMD = AppMode(2, "rmd-shiny", "Shiny App (Rmd)")
STATIC = AppMode(4, "static", "Static HTML", ".html")
PLUMBER = AppMode(5, "api", "API")
SHINY = AppMode(1, "shiny", "Shiny App", ".R", AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_SHINYAPPSIO | AppMode.DEPLOY_TARGET_CONNECT)
RMD = AppMode(3, "rmd-static", "R Markdown", ".Rmd", AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
SHINY_RMD = AppMode(2, "rmd-shiny", "Shiny App (Rmd)", None, AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_SHINYAPPSIO | AppMode.DEPLOY_TARGET_CONNECT)
STATIC = AppMode(4, "static", "Static HTML", ".html", AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
PLUMBER = AppMode(5, "api", "API", ".R", AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
TENSORFLOW = AppMode(6, "tensorflow-saved-model", "TensorFlow Model")
JUPYTER_NOTEBOOK = AppMode(7, "jupyter-static", "Jupyter Notebook", ".ipynb")
PYTHON_API = AppMode(8, "python-api", "Python API")
DASH_APP = AppMode(9, "python-dash", "Dash Application")
PYTHON_API = AppMode(8, "python-api", "Python API", None, AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
DASH_APP = AppMode(9, "python-dash", "Dash Application", None, AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
STREAMLIT_APP = AppMode(10, "python-streamlit", "Streamlit Application")
BOKEH_APP = AppMode(11, "python-bokeh", "Bokeh Application")
PYTHON_FASTAPI = AppMode(12, "python-fastapi", "Python FastAPI")
SHINY_QUARTO = AppMode(13, "quarto-shiny", "Shiny Quarto Document")
STATIC_QUARTO = AppMode(14, "quarto-static", "Quarto Document", ".qmd")
PYTHON_SHINY = AppMode(15, "python-shiny", "Python Shiny Application")
BOKEH_APP = AppMode(11, "python-bokeh", "Bokeh Application", None, AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
PYTHON_FASTAPI = AppMode(12, "python-fastapi", "Python FastAPI", None, AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
SHINY_QUARTO = AppMode(13, "quarto-shiny", "Shiny Quarto Document", None, AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT | AppMode.DEPLOY_TARGET_SHINYAPPSIO)
STATIC_QUARTO = AppMode(14, "quarto-static", "Quarto Document", ".qmd", AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT)
PYTHON_SHINY = AppMode(15, "python-shiny", "Python Shiny Application", None, AppMode.DEPLOY_TARGET_CLOUD | AppMode.DEPLOY_TARGET_CONNECT | AppMode.DEPLOY_TARGET_SHINYAPPSIO)
JUPYTER_VOILA = AppMode(16, "jupyter-voila", "Jupyter Voila Application")

_modes = [
Expand Down
Loading