diff --git a/src/cleveragents/cli/commands/project.py b/src/cleveragents/cli/commands/project.py index b8c6f7418..82a6d08fd 100644 --- a/src/cleveragents/cli/commands/project.py +++ b/src/cleveragents/cli/commands/project.py @@ -1040,7 +1040,7 @@ def switch( # Validate project exists try: proj = svc.get_project(project) - except Exception as exc: + except NotFoundError as exc: err_console.print(f"[red]Project not found:[/red] {project}") raise typer.Exit(1) from exc @@ -1086,7 +1086,7 @@ def switch( "description": proj.description, "updated_at": datetime.now(tz=UTC).isoformat(), } - console.print(format_output(data, output_format)) + console.print(format_output(data, output_format, command="project switch")) def _write_active_project(namespaced_name: str) -> None: @@ -1100,8 +1100,9 @@ def _write_active_project(namespaced_name: str) -> None: home = Path.home() / ".cleveragents" home.mkdir(parents=True, exist_ok=True) helper_path = home / "active-project.sh" + safe_name = namespaced_name.replace("'", "'\\''") helper_path.write_text( - f'export CLEVERAGENTS_PROJECT="{namespaced_name}"\n', encoding="utf-8" + f"export CLEVERAGENTS_PROJECT='{safe_name}'\n", encoding="utf-8" ) # Also update the in-memory environment for the current process and any