Skip to content

Commit e62ea35

Browse files
Merge pull request #502 from VWS-Python/env-var-format
Add option to format database details as env vars, for use with VWS-P…
2 parents 483f6a7 + fd78ba1 commit e62ea35

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

admin/update_cli_tests.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# There are CLI tests which check that --help output for various commands is
4+
# as expected.
5+
#
6+
# Expected output is stored in files.
7+
# This script updates those files.
8+
#
9+
# The expected use of this script:
10+
# * Make a change which changes expected help text for CLI commands
11+
# * Run this script
12+
# * Inspect the diff to check that changes are as expected
13+
# * Commit and push
14+
15+
set -euxo pipefail
16+
17+
export FIX_CLI_TESTS=1
18+
19+
mkdir -p tests/help_outputs
20+
git rm -f tests/help_outputs/*.txt || true
21+
pytest tests/test_help.py || true
22+
git add tests/help_outputs/*.txt

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ ignore_path = [
107107

108108
ignore = [
109109
"*.enc",
110+
"admin",
111+
"admin/**",
110112
"readthedocs.yaml",
111113
"CHANGELOG.rst",
112114
"CODE_OF_CONDUCT.rst",

src/vws_web_tools/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,13 @@ def create_vws_database(
309309
@click.option("--database-name", required=True)
310310
@click.option("--email-address", envvar="VWS_EMAIL_ADDRESS", required=True)
311311
@click.option("--password", envvar="VWS_PASSWORD", required=True)
312+
@click.option("--env-var-format", is_flag=True)
312313
def show_database_details(
313314
database_name: str,
314315
email_address: str,
315316
password: str,
317+
*,
318+
env_var_format: bool,
316319
) -> None: # pragma: no cover
317320
"""
318321
Show the details of a database.
@@ -322,7 +325,19 @@ def show_database_details(
322325
wait_for_logged_in(driver=driver)
323326
details = get_database_details(driver=driver, database_name=database_name)
324327
driver.close()
325-
click.echo(yaml.dump(details), nl=False)
328+
if env_var_format:
329+
env_var_format_details = {
330+
"VUFORIA_TARGET_MANAGER_DATABASE_NAME": details["database_name"],
331+
"VUFORIA_SERVER_ACCESS_KEY": details["server_access_key"],
332+
"VUFORIA_SERVER_SECRET_KEY": details["server_secret_key"],
333+
"VUFORIA_CLIENT_ACCESS_KEY": details["client_access_key"],
334+
"VUFORIA_CLIENT_SECRET_KEY": details["client_secret_key"],
335+
}
336+
337+
for key, value in env_var_format_details.items():
338+
click.echo(f"{key}={value}")
339+
else:
340+
click.echo(yaml.dump(details), nl=False)
326341

327342

328343
vws_web_tools_group.add_command(create_vws_database)

tests/help_outputs/vws-show-database-details.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Options:
66
--database-name TEXT [required]
77
--email-address TEXT [required]
88
--password TEXT [required]
9+
--env-var-format
910
--help Show this message and exit.
File renamed without changes.

0 commit comments

Comments
 (0)