From 5ddd7ad8e571a9abec40b3d4cc51efc1266f0c10 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 15 Sep 2022 12:06:58 -0400 Subject: [PATCH 01/22] fix bug where -n and -k was mutually exclusive --- rsconnect/validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsconnect/validation.py b/rsconnect/validation.py index 561f82cd..0fdf9d18 100644 --- a/rsconnect/validation.py +++ b/rsconnect/validation.py @@ -14,7 +14,7 @@ def validate_connection_options(url, api_key, insecure, cacert, account_name, to """ connect_options = {"-k/--api-key": api_key, "-i/--insecure": insecure, "-c/--cacert": cacert} shinyapps_options = {"-T/--token": token, "-S/--secret": secret, "-A/--account": account_name} - options_mutually_exclusive_with_name = {"-s/--server": url, **connect_options, **shinyapps_options} + options_mutually_exclusive_with_name = {"-s/--server": url, **shinyapps_options} present_options_mutually_exclusive_with_name = _get_present_options(options_mutually_exclusive_with_name) if name and present_options_mutually_exclusive_with_name: From b18bf7451a4076797b9cd90f3eb7ee3d89d528fb Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 15 Sep 2022 17:56:11 -0400 Subject: [PATCH 02/22] allow partial override of stored from cli --- rsconnect/api.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index 87840477..145faf2e 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -404,12 +404,12 @@ def setup_remote_server( server_data = ServerStore().resolve(name, url) if server_data.from_store: url = server_data.url - api_key = server_data.api_key - insecure = server_data.insecure - ca_data = server_data.ca_data - account_name = server_data.account_name - token = server_data.token - secret = server_data.secret + api_key = api_key or server_data.api_key + insecure = insecure or server_data.insecure + ca_data = ca_data or server_data.ca_data + account_name = account_name or server_data.account_name + token = token or server_data.token + secret = secret or server_data.secret self.is_server_from_store = server_data.from_store if api_key: From 1439bd99253fef5fed227154ff47c0b6b0025bec Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 11:07:22 -0400 Subject: [PATCH 03/22] Revert "allow partial override of stored from cli" This reverts commit b18bf7451a4076797b9cd90f3eb7ee3d89d528fb. --- rsconnect/api.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index 145faf2e..87840477 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -404,12 +404,12 @@ def setup_remote_server( server_data = ServerStore().resolve(name, url) if server_data.from_store: url = server_data.url - api_key = api_key or server_data.api_key - insecure = insecure or server_data.insecure - ca_data = ca_data or server_data.ca_data - account_name = account_name or server_data.account_name - token = token or server_data.token - secret = secret or server_data.secret + api_key = server_data.api_key + insecure = server_data.insecure + ca_data = server_data.ca_data + account_name = server_data.account_name + token = server_data.token + secret = server_data.secret self.is_server_from_store = server_data.from_store if api_key: From 20b00cfab8e6143834649c5164a1ca85514b11eb Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 11:07:58 -0400 Subject: [PATCH 04/22] test modified prelease --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d32b730..2df5995c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: - uses: actions/setup-python@v2 with: python-version: 3.8.x - - run: pip install --pre -r requirements.txt + - run: pip install -r requirements.txt - run: pip freeze - run: make fmt - run: make lint From cd2a678d23a2e3e2f8439a480aa5e3312a50c1da Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 11:33:49 -0400 Subject: [PATCH 05/22] cat mock_connect.log --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e4563d62..0487f402 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ mock-test-%: clean-stores CONNECT_CONTENT_BUILD_DIR="rsconnect-build-test" \ CONNECT_SERVER="http://$(HOSTNAME):3939" \ CONNECT_API_KEY="0123456789abcdef0123456789abcdef" \ - $(MAKE) test-$* + $(MAKE) test-$* || cat mock_connect.log @$(MAKE) -C mock_connect down fmt-%: From 5860b16598dc469d083ad107e8c0247a1563fe1f Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 11:39:45 -0400 Subject: [PATCH 06/22] correct mock_connect.log location --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0487f402..ac7aacc8 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ mock-test-%: clean-stores CONNECT_CONTENT_BUILD_DIR="rsconnect-build-test" \ CONNECT_SERVER="http://$(HOSTNAME):3939" \ CONNECT_API_KEY="0123456789abcdef0123456789abcdef" \ - $(MAKE) test-$* || cat mock_connect.log + $(MAKE) test-$* || cat mock_connect/mock_connect.log @$(MAKE) -C mock_connect down fmt-%: From 1859177f6a35901239498cf3d001735b69d0dca1 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 12:00:29 -0400 Subject: [PATCH 07/22] Revert "correct mock_connect.log location" This reverts commit 5860b16598dc469d083ad107e8c0247a1563fe1f. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ac7aacc8..0487f402 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ mock-test-%: clean-stores CONNECT_CONTENT_BUILD_DIR="rsconnect-build-test" \ CONNECT_SERVER="http://$(HOSTNAME):3939" \ CONNECT_API_KEY="0123456789abcdef0123456789abcdef" \ - $(MAKE) test-$* || cat mock_connect/mock_connect.log + $(MAKE) test-$* || cat mock_connect.log @$(MAKE) -C mock_connect down fmt-%: From 3e56bb43de83bd54877363d93e600895a20f3764 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 12:02:17 -0400 Subject: [PATCH 08/22] Revert "cat mock_connect.log" This reverts commit cd2a678d23a2e3e2f8439a480aa5e3312a50c1da. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0487f402..e4563d62 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ mock-test-%: clean-stores CONNECT_CONTENT_BUILD_DIR="rsconnect-build-test" \ CONNECT_SERVER="http://$(HOSTNAME):3939" \ CONNECT_API_KEY="0123456789abcdef0123456789abcdef" \ - $(MAKE) test-$* || cat mock_connect.log + $(MAKE) test-$* @$(MAKE) -C mock_connect down fmt-%: From 2ad0f5b54d1f79c0a4152b9d31556b637ce703be Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 12:02:35 -0400 Subject: [PATCH 09/22] Revert "test modified prelease" This reverts commit 20b00cfab8e6143834649c5164a1ca85514b11eb. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2df5995c..5d32b730 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: - uses: actions/setup-python@v2 with: python-version: 3.8.x - - run: pip install -r requirements.txt + - run: pip install --pre -r requirements.txt - run: pip freeze - run: make fmt - run: make lint From 0444591dd00ae3897bf88933e5fe1fa1787f4ab0 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 13:13:51 -0400 Subject: [PATCH 10/22] add warning when stored credentials already exist --- rsconnect/api.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index 87840477..0d38cfe7 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -404,12 +404,30 @@ def setup_remote_server( server_data = ServerStore().resolve(name, url) if server_data.from_store: url = server_data.url - api_key = server_data.api_key - insecure = server_data.insecure - ca_data = server_data.ca_data - account_name = server_data.account_name - token = server_data.token - secret = server_data.secret + if ( + server_data.api_key + and api_key + or server_data.insecure + and insecure + or server_data.ca_data + and ca_data + or server_data.account_name + and account_name + or server_data.token + and token + or server_data.secret + and secret + ): + warn( + "Connect will use non-empty stored credentials. CLI credentials and environment credential variables are ignored.", + stacklevel=2, + ) + api_key = server_data.api_key or api_key + insecure = server_data.insecure or insecure + ca_data = server_data.ca_data or ca_data + account_name = server_data.account_name or account_name + token = server_data.token or token + secret = server_data.secret or secret self.is_server_from_store = server_data.from_store if api_key: From 05d256a3c97c3f1b99353cd9d2982ce20adf0cd8 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Fri, 16 Sep 2022 13:18:13 -0400 Subject: [PATCH 11/22] shorten warning length for flake8 --- rsconnect/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index 0d38cfe7..e7eb40da 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -419,7 +419,7 @@ def setup_remote_server( and secret ): warn( - "Connect will use non-empty stored credentials. CLI credentials and environment credential variables are ignored.", + "Connect will use non-empty stored credentials. CLI & environment credentials are ignored.", stacklevel=2, ) api_key = server_data.api_key or api_key From 8695b004db60e136f8f0a5d21ec89c65bf4656f6 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Mon, 19 Sep 2022 16:32:09 -0400 Subject: [PATCH 12/22] make list server check not error out on None fields --- rsconnect/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rsconnect/main.py b/rsconnect/main.py index 97b431d9..0d81795f 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -386,9 +386,9 @@ def list_servers(verbose): click.echo('Nickname: "%s"' % server["name"]) click.echo(" URL: %s" % server["url"]) click.echo(" API key is saved") - if server["insecure"]: + if server.get("insecure"): click.echo(" Insecure mode (TLS host/certificate validation disabled)") - if server["ca_cert"]: + if server.get("ca_cert"): click.echo(" Client TLS certificate data provided") click.echo() From 7a14e71b4e05e428b890005b2ff5698f5ee7f92c Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Mon, 19 Sep 2022 16:35:46 -0400 Subject: [PATCH 13/22] correct display of "API key is saved" message --- rsconnect/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rsconnect/main.py b/rsconnect/main.py index 0d81795f..8f63c5c5 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -385,7 +385,8 @@ def list_servers(verbose): for server in servers: click.echo('Nickname: "%s"' % server["name"]) click.echo(" URL: %s" % server["url"]) - click.echo(" API key is saved") + if server.get("api_key"): + click.echo(" API key is saved") if server.get("insecure"): click.echo(" Insecure mode (TLS host/certificate validation disabled)") if server.get("ca_cert"): From c163e890f053ae0df4bc46ef5ebf750e854b0334 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Mon, 19 Sep 2022 16:43:13 -0400 Subject: [PATCH 14/22] remove stack level from warning --- rsconnect/api.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index e7eb40da..d8920ec3 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -418,10 +418,7 @@ def setup_remote_server( or server_data.secret and secret ): - warn( - "Connect will use non-empty stored credentials. CLI & environment credentials are ignored.", - stacklevel=2, - ) + warn("Connect will use non-empty stored credentials. CLI & environment credentials are ignored.") api_key = server_data.api_key or api_key insecure = server_data.insecure or insecure ca_data = server_data.ca_data or ca_data From ee46ae88f3fcbd266f3b85c23617875caab0eedf Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Mon, 19 Sep 2022 17:04:19 -0400 Subject: [PATCH 15/22] update message and output to logging --- rsconnect/api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index d8920ec3..8b3106e4 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -338,6 +338,7 @@ def __init__( ) -> None: self.reset() self._d = kwargs + self.logger = logger self.setup_remote_server( name=name, url=url or kwargs.get("server"), @@ -350,7 +351,6 @@ def __init__( secret=secret, ) self.setup_client(cookies, timeout) - self.logger = logger @classmethod def fromConnectServer(cls, connect_server, **kwargs): @@ -418,7 +418,13 @@ def setup_remote_server( or server_data.secret and secret ): - warn("Connect will use non-empty stored credentials. CLI & environment credentials are ignored.") + # warn("Connect will use non-empty stored credentials. CLI & environment credentials are ignored.") + self.logger.warning( + "Connect has detected that a CLI and/or environment variable overlaps with a stored credential.\n" + ) + self.logger.warning( + "Non-empty stored credentials will be used and CLI and/or environment variable are ignored.\n" + ) api_key = server_data.api_key or api_key insecure = server_data.insecure or insecure ca_data = server_data.ca_data or ca_data From 46ba9d7cdbc23b6d957b73ae7e73f61390c6379d Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Mon, 19 Sep 2022 17:13:43 -0400 Subject: [PATCH 16/22] handle no logger case --- rsconnect/api.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index 8b3106e4..22d8c84c 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -418,13 +418,13 @@ def setup_remote_server( or server_data.secret and secret ): - # warn("Connect will use non-empty stored credentials. CLI & environment credentials are ignored.") - self.logger.warning( - "Connect has detected that a CLI and/or environment variable overlaps with a stored credential.\n" - ) - self.logger.warning( - "Non-empty stored credentials will be used and CLI and/or environment variable are ignored.\n" - ) + if self.logger: + self.logger.warning( + "Connect has detected that a CLI and/or environment variable overlaps with a stored credential.\n" + ) + self.logger.warning( + "Non-empty stored credentials will be used and CLI and/or environment variable are ignored.\n" + ) api_key = server_data.api_key or api_key insecure = server_data.insecure or insecure ca_data = server_data.ca_data or ca_data From 366dc0761be97807134284f1a354a6b9cecc9efd Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Mon, 19 Sep 2022 17:22:04 -0400 Subject: [PATCH 17/22] make logger required to show warning --- rsconnect/api.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index 22d8c84c..bfe67f0a 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -417,14 +417,13 @@ def setup_remote_server( and token or server_data.secret and secret - ): - if self.logger: - self.logger.warning( - "Connect has detected that a CLI and/or environment variable overlaps with a stored credential.\n" - ) - self.logger.warning( - "Non-empty stored credentials will be used and CLI and/or environment variable are ignored.\n" - ) + ) and self.logger: + self.logger.warning( + "Connect has detected that a CLI and/or environment variable overlaps with a stored credential.\n" + ) + self.logger.warning( + "Non-empty stored credentials will be used and CLI and/or environment variable are ignored.\n" + ) api_key = server_data.api_key or api_key insecure = server_data.insecure or insecure ca_data = server_data.ca_data or ca_data From 6cb4d6f5f79d70426e0849e810b6f4d8044bd0ce Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Tue, 27 Sep 2022 14:42:26 -0400 Subject: [PATCH 18/22] Show detected inputs when adding --- rsconnect/main.py | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/rsconnect/main.py b/rsconnect/main.py index 8f63c5c5..3305a1ef 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -287,38 +287,18 @@ def _test_shinyappsio_creds(server: api.ShinyappsServer): "on the command line." ), ) -@click.option("--name", "-n", required=True, help="The nickname of the RStudio Connect server to deploy to.") -@click.option( - "--server", - "-s", - envvar="CONNECT_SERVER", - help="The URL for the RStudio Connect server to deploy to.", -) -@click.option( - "--api-key", - "-k", - envvar="CONNECT_API_KEY", - help="The API key to use to authenticate with RStudio Connect.", -) -@click.option( - "--insecure", - "-i", - envvar="CONNECT_INSECURE", - is_flag=True, - help="Disable TLS certification/host validation.", -) -@click.option( - "--cacert", - "-c", - envvar="CONNECT_CA_CERTIFICATE", - type=click.File(), - help="The path to trusted TLS CA certificates.", -) +@server_args @shinyapps_args -@click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.") -def add(name, server, api_key, insecure, cacert, account, token, secret, verbose): +@click.pass_context +def add(ctx, name, server, api_key, insecure, cacert, account, token, secret, verbose): set_verbosity(verbose) + click.echo("Detected the following inputs:") + for k, v in locals().items(): + if k in {"ctx", "verbose"}: + continue + if v is not None: + click.echo(" {}: {}".format(k, ctx.get_parameter_source(k).name)) validation.validate_connection_options( url=server, From 4dfb46ca322911befd14589d7a6b1b767f47eb1f Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Tue, 27 Sep 2022 15:23:17 -0400 Subject: [PATCH 19/22] Update credential overlap warning messages --- rsconnect/api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rsconnect/api.py b/rsconnect/api.py index bfe67f0a..038e1827 100644 --- a/rsconnect/api.py +++ b/rsconnect/api.py @@ -419,10 +419,16 @@ def setup_remote_server( and secret ) and self.logger: self.logger.warning( - "Connect has detected that a CLI and/or environment variable overlaps with a stored credential.\n" + "Connect detected CLI commands and/or environment variables that overlap with stored credential.\n" ) self.logger.warning( - "Non-empty stored credentials will be used and CLI and/or environment variable are ignored.\n" + "Check your environment variables (e.g. CONNECT_API_KEY) to make sure you want them to be used.\n" + ) + self.logger.warning( + "Credential paremeters are taken with the following precedence: stored > CLI > environment.\n" + ) + self.logger.warning( + "To ignore an environment variable, override it in the CLI with an empty string (e.g. -k '').\n" ) api_key = server_data.api_key or api_key insecure = server_data.insecure or insecure From aeb8db4d5a4897f7b1495a8d5b3ee7c6479b5e92 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Tue, 27 Sep 2022 15:50:33 -0400 Subject: [PATCH 20/22] Revert "Show detected inputs when adding" This reverts commit 6cb4d6f5f79d70426e0849e810b6f4d8044bd0ce. --- rsconnect/main.py | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/rsconnect/main.py b/rsconnect/main.py index 3305a1ef..8f63c5c5 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -287,18 +287,38 @@ def _test_shinyappsio_creds(server: api.ShinyappsServer): "on the command line." ), ) -@server_args +@click.option("--name", "-n", required=True, help="The nickname of the RStudio Connect server to deploy to.") +@click.option( + "--server", + "-s", + envvar="CONNECT_SERVER", + help="The URL for the RStudio Connect server to deploy to.", +) +@click.option( + "--api-key", + "-k", + envvar="CONNECT_API_KEY", + help="The API key to use to authenticate with RStudio Connect.", +) +@click.option( + "--insecure", + "-i", + envvar="CONNECT_INSECURE", + is_flag=True, + help="Disable TLS certification/host validation.", +) +@click.option( + "--cacert", + "-c", + envvar="CONNECT_CA_CERTIFICATE", + type=click.File(), + help="The path to trusted TLS CA certificates.", +) @shinyapps_args -@click.pass_context -def add(ctx, name, server, api_key, insecure, cacert, account, token, secret, verbose): +@click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.") +def add(name, server, api_key, insecure, cacert, account, token, secret, verbose): set_verbosity(verbose) - click.echo("Detected the following inputs:") - for k, v in locals().items(): - if k in {"ctx", "verbose"}: - continue - if v is not None: - click.echo(" {}: {}".format(k, ctx.get_parameter_source(k).name)) validation.validate_connection_options( url=server, From e5b465c742bf36d8e937967d221c3c3dddaf0da2 Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Tue, 27 Sep 2022 16:38:10 -0400 Subject: [PATCH 21/22] Show detected inputs when adding --- rsconnect/main.py | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/rsconnect/main.py b/rsconnect/main.py index 8f63c5c5..7f50f946 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -287,38 +287,19 @@ def _test_shinyappsio_creds(server: api.ShinyappsServer): "on the command line." ), ) -@click.option("--name", "-n", required=True, help="The nickname of the RStudio Connect server to deploy to.") -@click.option( - "--server", - "-s", - envvar="CONNECT_SERVER", - help="The URL for the RStudio Connect server to deploy to.", -) -@click.option( - "--api-key", - "-k", - envvar="CONNECT_API_KEY", - help="The API key to use to authenticate with RStudio Connect.", -) -@click.option( - "--insecure", - "-i", - envvar="CONNECT_INSECURE", - is_flag=True, - help="Disable TLS certification/host validation.", -) -@click.option( - "--cacert", - "-c", - envvar="CONNECT_CA_CERTIFICATE", - type=click.File(), - help="The path to trusted TLS CA certificates.", -) +@server_args @shinyapps_args -@click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.") -def add(name, server, api_key, insecure, cacert, account, token, secret, verbose): +@click.pass_context +def add(ctx, name, server, api_key, insecure, cacert, account, token, secret, verbose): set_verbosity(verbose) + if sys.version_info >= (3, 8): + click.echo("Detected the following inputs:") + for k, v in locals().items(): + if k in {"ctx", "verbose"}: + continue + if v is not None: + click.echo(" {}: {}".format(k, ctx.get_parameter_source(k).name)) validation.validate_connection_options( url=server, From f8ea20eb07c41f9ef6c33189169be78e938558ca Mon Sep 17 00:00:00 2001 From: Bincheng Wu Date: Thu, 29 Sep 2022 10:24:56 -0400 Subject: [PATCH 22/22] add back -n as required on add --- rsconnect/main.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/rsconnect/main.py b/rsconnect/main.py index 7f50f946..daba93ba 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -287,7 +287,34 @@ def _test_shinyappsio_creds(server: api.ShinyappsServer): "on the command line." ), ) -@server_args +@click.option("--name", "-n", required=True, help="The nickname of the RStudio Connect server to deploy to.") +@click.option( + "--server", + "-s", + envvar="CONNECT_SERVER", + help="The URL for the RStudio Connect server to deploy to.", +) +@click.option( + "--api-key", + "-k", + envvar="CONNECT_API_KEY", + help="The API key to use to authenticate with RStudio Connect.", +) +@click.option( + "--insecure", + "-i", + envvar="CONNECT_INSECURE", + is_flag=True, + help="Disable TLS certification/host validation.", +) +@click.option( + "--cacert", + "-c", + envvar="CONNECT_CA_CERTIFICATE", + type=click.File(), + help="The path to trusted TLS CA certificates.", +) +@click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.") @shinyapps_args @click.pass_context def add(ctx, name, server, api_key, insecure, cacert, account, token, secret, verbose):