From 472aba59901f989c74b62f8dc3319046f607c563 Mon Sep 17 00:00:00 2001 From: edraft Date: Sun, 19 Oct 2025 20:03:43 +0200 Subject: [PATCH] Removed ws with_parents --- src/cli/cpl/cli/command/structure/init.py | 2 +- src/cli/cpl/cli/command/structure/new.py | 2 +- src/cli/cpl/cli/utils/structure.py | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cli/cpl/cli/command/structure/init.py b/src/cli/cpl/cli/command/structure/init.py index c33a5401..f6b53ebd 100644 --- a/src/cli/cpl/cli/command/structure/init.py +++ b/src/cli/cpl/cli/command/structure/init.py @@ -31,7 +31,7 @@ def init(target: str, name: str, verbose: bool = False): if target in ["workspace", "ws"]: workspace = Structure.init_workspace("./", name or click.prompt("Workspace name", default="my-workspace")) elif target in PROJECT_TYPES: - workspace = Structure.find_workspace_in_path(Path(name or "./").parent, with_parents=True) + workspace = Structure.find_workspace_in_path(Path(name or "./").parent) project = Structure.init_project( "./", name or click.prompt("Project name", default=f"my-{target}"), target, workspace, verbose=verbose ) diff --git a/src/cli/cpl/cli/command/structure/new.py b/src/cli/cpl/cli/command/structure/new.py index 7476d8c0..434ea435 100644 --- a/src/cli/cpl/cli/command/structure/new.py +++ b/src/cli/cpl/cli/command/structure/new.py @@ -44,7 +44,7 @@ def new(type: str, name: str, in_name: str | None, project: list[str] | None, ve path = Path(workspace.path).parent / Path(project[1]).parent project_name = Path(project[1]).stem - workspace = Structure.find_workspace_in_path(path, with_parents=False) + workspace = Structure.find_workspace_in_path(path) if workspace is None: Console.error("No workspace found. Please run 'cpl init workspace' first.") raise SystemExit(1) diff --git a/src/cli/cpl/cli/utils/structure.py b/src/cli/cpl/cli/utils/structure.py index 1b2e15cd..7ba3849f 100644 --- a/src/cli/cpl/cli/utils/structure.py +++ b/src/cli/cpl/cli/utils/structure.py @@ -32,11 +32,9 @@ class Structure: } @staticmethod - def find_workspace_in_path(path: Path, with_parents=False) -> Workspace | None: + def find_workspace_in_path(path: Path) -> Workspace | None: current_path = path.resolve() - paths = [current_path] - if with_parents: - paths.extend(current_path.parents) + paths = [current_path, *current_path.parents] for parent in paths: workspace_file = parent / "cpl.workspace.json" @@ -84,7 +82,7 @@ class Structure: return Project.from_file(path) - workspace = Structure.find_workspace_in_path(path.parent, with_parents=True) + workspace = Structure.find_workspace_in_path(path.parent) if workspace is None: raise RuntimeError("No workspace found. Please run 'cpl init workspace' first.")