MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / open_project

Function open_project

unity_cli/cli/commands/open_cmd.py:16–49  ·  view source on GitHub ↗

Open Unity project with appropriate editor version. Reads ProjectSettings/ProjectVersion.txt to detect required version. If version not installed, prompts for action.

(
        path: Annotated[Path, typer.Argument(help="Unity project path")],
        editor_version: Annotated[
            str | None,
            typer.Option("--editor", "-e", help="Override editor version"),
        ] = None,
        non_interactive: Annotated[
            bool,
            typer.Option("--non-interactive", "-y", help="Fail instead of prompting"),
        ] = False,
        wait: Annotated[
            bool,
            typer.Option("--wait", "-w", help="Wait for editor to close"),
        ] = False,
    )

Source from the content-addressed store, hash-verified

14def register(app: typer.Typer) -> None:
15 @app.command("open")
16 def open_project(
17 path: Annotated[Path, typer.Argument(help="Unity project path")],
18 editor_version: Annotated[
19 str | None,
20 typer.Option("--editor", "-e", help="Override editor version"),
21 ] = None,
22 non_interactive: Annotated[
23 bool,
24 typer.Option("--non-interactive", "-y", help="Fail instead of prompting"),
25 ] = False,
26 wait: Annotated[
27 bool,
28 typer.Option("--wait", "-w", help="Wait for editor to close"),
29 ] = False,
30 ) -> None:
31 """Open Unity project with appropriate editor version.
32
33 Reads ProjectSettings/ProjectVersion.txt to detect required version.
34 If version not installed, prompts for action.
35 """
36 from unity_cli.exceptions import EditorNotFoundError, ProjectError
37 from unity_cli.hub.service import HubService
38
39 try:
40 service = HubService()
41 service.open_project(
42 project_path=path,
43 editor_override=editor_version,
44 non_interactive=non_interactive,
45 wait=wait,
46 )
47 print_success(f"Opened project: {path}")
48 except (ProjectError, EditorNotFoundError) as e:
49 _handle_error(e)

Callers

nothing calls this directly

Calls 4

open_projectMethod · 0.95
HubServiceClass · 0.90
print_successFunction · 0.90
_handle_errorFunction · 0.90

Tested by

no test coverage detected