feat(cli): add --json to deploy listeners list

The table output isn't scriptable, so a deploy automation pipeline
has no reliable way to extract a listener's id to pass to
--listener-id. --json prints the listeners as a JSON array instead
(an empty array when there are none, so callers never need to
special-case the human-readable "no listeners" message).
This commit is contained in:
gdibben
2026-10-08 07:57:05 +01:00
parent 40a2e6d845
commit 48b2346e33
2 changed files with 86 additions and 1 deletions
+13 -1
View File
@@ -2518,6 +2518,13 @@ def deploy_listeners() -> None:
@OPT_HOST_API_KEY
@OPT_HOST_URL
@click.option(
"--json",
"json_output",
is_flag=True,
default=False,
help="Emit the listeners as a JSON array instead of a table.",
)
@deploy_listeners.command(
"list",
help=(
@@ -2526,11 +2533,16 @@ def deploy_listeners() -> None:
"--listener-id <id>` to deploy through it."
),
)
def deploy_listeners_list(api_key: str | None, host_url: str | None) -> None:
def deploy_listeners_list(
api_key: str | None, host_url: str | None, json_output: bool
) -> None:
client = _create_host_backend_client(host_url, api_key)
listeners = _call_host_backend_with_optional_tenant(
client, lambda c: c.list_listeners()
)
if json_output:
click.echo(json_mod.dumps(listeners))
return
if not listeners:
click.echo("No listeners found for this workspace.")
return