diff --git a/src/specify_cli/integrations/catalog/command_remove.py b/src/specify_cli/integrations/catalog/command_remove.py index b9a7a37f00..9edd617472 100644 --- a/src/specify_cli/integrations/catalog/command_remove.py +++ b/src/specify_cli/integrations/catalog/command_remove.py @@ -3,6 +3,7 @@ import typer +from rich.markup import escape as _rich_escape from ..._console import console from . import catalog_app @@ -25,4 +26,5 @@ def integration_catalog_remove( console.print(f"[red]Error:[/red] {exc}") raise typer.Exit(1) - console.print(f"[green]✓[/green] Catalog source '{removed_name}' removed") + safe_name = _rich_escape(removed_name) + console.print(f"[green]✓[/green] Catalog source '{safe_name}' removed") diff --git a/src/specify_cli/workflows/catalog/command_remove.py b/src/specify_cli/workflows/catalog/command_remove.py index 4240e6cdbf..dd589ab2a2 100644 --- a/src/specify_cli/workflows/catalog/command_remove.py +++ b/src/specify_cli/workflows/catalog/command_remove.py @@ -23,4 +23,5 @@ def workflow_catalog_remove( cli.console.print(f"[red]Error:[/red] {exc}") raise cli.typer.Exit(1) - cli.console.print(f"[green]✓[/green] Catalog source '{removed_name}' removed") + safe_name = cli._escape_markup(removed_name) + cli.console.print(f"[green]✓[/green] Catalog source '{safe_name}' removed") diff --git a/src/specify_cli/workflows/step/catalog/command_remove.py b/src/specify_cli/workflows/step/catalog/command_remove.py index 6eba4f8530..90edbe07bf 100644 --- a/src/specify_cli/workflows/step/catalog/command_remove.py +++ b/src/specify_cli/workflows/step/catalog/command_remove.py @@ -24,4 +24,5 @@ def workflow_step_catalog_remove( cli.console.print(f"[red]Error:[/red] {exc}") raise cli.typer.Exit(1) - cli.console.print(f"[green]✓[/green] Step catalog source '{removed_name}' removed") + safe_name = cli._escape_markup(removed_name) + cli.console.print(f"[green]✓[/green] Step catalog source '{safe_name}' removed") diff --git a/tests/specify_cli/integrations/catalog/test_command_remove.py b/tests/specify_cli/integrations/catalog/test_command_remove.py index 3174d94173..9e832334cc 100644 --- a/tests/specify_cli/integrations/catalog/test_command_remove.py +++ b/tests/specify_cli/integrations/catalog/test_command_remove.py @@ -45,6 +45,30 @@ def test_catalog_remove_out_of_range(self, tmp_path, monkeypatch): assert result.exit_code == 1 assert "out of range" in result.output + def test_catalog_remove_prints_bracketed_name_literally( + self, tmp_path, monkeypatch + ): + project = self._make_project(tmp_path) + monkeypatch.delenv("SPECKIT_INTEGRATION_CATALOG_URL", raising=False) + add = self._invoke( + [ + "integration", + "catalog", + "add", + "https://only.example.com/catalog.json", + "--name", + "QA [/beta]", + ], + project, + ) + assert add.exit_code == 0, add.output + + remove = self._invoke( + ["integration", "catalog", "remove", "0"], project + ) + assert remove.exit_code == 0, remove.output + assert "'QA [/beta]' removed" in remove.output + def test_catalog_remove_without_config(self, tmp_path, monkeypatch): project = self._make_project(tmp_path) result = self._invoke( diff --git a/tests/specify_cli/workflows/catalog/test_command_remove.py b/tests/specify_cli/workflows/catalog/test_command_remove.py index 2b01d78830..c8abcdd90b 100644 --- a/tests/specify_cli/workflows/catalog/test_command_remove.py +++ b/tests/specify_cli/workflows/catalog/test_command_remove.py @@ -23,6 +23,20 @@ def test_workflow_catalog_remove_deletes_selected_source(project_dir, monkeypatc ) +def test_workflow_catalog_remove_prints_bracketed_name_literally( + project_dir, monkeypatch +): + monkeypatch.chdir(project_dir) + monkeypatch.delenv("SPECKIT_WORKFLOW_CATALOG_URL", raising=False) + catalog = WorkflowCatalog(project_dir) + catalog.add_catalog("https://example.com/workflows.json", "QA [/beta]") + + result = CliRunner().invoke(app, ["workflow", "catalog", "remove", "0"]) + + assert result.exit_code == 0, result.output + assert "'QA [/beta]' removed" in result.output + + def test_workflow_catalog_remove_uses_listed_index(project_dir, monkeypatch): monkeypatch.chdir(project_dir) monkeypatch.delenv("SPECKIT_WORKFLOW_CATALOG_URL", raising=False) diff --git a/tests/specify_cli/workflows/step/catalog/test_command_remove.py b/tests/specify_cli/workflows/step/catalog/test_command_remove.py index 645fb4e8de..9acd750f6d 100644 --- a/tests/specify_cli/workflows/step/catalog/test_command_remove.py +++ b/tests/specify_cli/workflows/step/catalog/test_command_remove.py @@ -27,6 +27,22 @@ def test_workflow_step_catalog_remove_deletes_selected_source( ) +def test_workflow_step_catalog_remove_prints_bracketed_name_literally( + project_dir, monkeypatch +): + monkeypatch.chdir(project_dir) + monkeypatch.delenv("SPECKIT_STEP_CATALOG_URL", raising=False) + catalog = StepCatalog(project_dir) + catalog.add_catalog("https://example.com/steps.json", "QA [/beta]") + + result = CliRunner().invoke( + app, ["workflow", "step", "catalog", "remove", "0"] + ) + + assert result.exit_code == 0, result.output + assert "'QA [/beta]' removed" in result.output + + def test_workflow_step_catalog_remove_uses_listed_index(project_dir, monkeypatch): monkeypatch.chdir(project_dir) monkeypatch.delenv("SPECKIT_STEP_CATALOG_URL", raising=False)