Skip to content
Merged
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
5 changes: 2 additions & 3 deletions src/pt_snap_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,8 @@ def query_database(
if template_info:
try:
info = query_service.get_template_info(template_info)
except TemplateNotFoundError:
typer.secho(f"Error: Template '{template_info}' not found", fg=typer.colors.RED)
raise typer.Exit() from None
except TemplateNotFoundError as e:
_error(str(e))

typer.secho(f"Template: {info.name}", fg=typer.colors.GREEN, bold=True)
typer.echo(f"Description: {info.description}")
Expand Down
5 changes: 2 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,8 @@ class TestQueryCommandErrors:
def test_query_template_info_not_found(self, sample_db: Path) -> None:
"""Test 'query --template-info' with non-existent template."""
result = runner.invoke(app, ["query", str(sample_db), "--template-info", "nonexistent"])
assert result.exit_code == 0
assert "Error" in result.stdout
assert "not found" in result.stdout
assert result.exit_code == 1
assert "Error: Template 'nonexistent' not found" in result.stdout

def test_query_without_template_use(self, sample_db: Path) -> None:
"""Test 'query' command without --template-use raises error."""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contract_cli_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def test_missing_template_error_contract_matches_cli_and_mcp_semantics(
) -> None:
template_name = "does_not_exist"
cli_result = runner.invoke(app, ["query", "--template-info", template_name])
assert cli_result.exit_code == 0
assert cli_result.exit_code == 1

assert _normalize_cli_missing_template(cli_result.stdout) == mcp_server.get_template_info(
template_name
Expand Down
Loading