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

Function project_version

unity_cli/cli/commands/project.py:115–142  ·  view source on GitHub ↗

Show Unity version for project.

(
    ctx: typer.Context,
    path: Annotated[
        Path,
        typer.Argument(help="Unity project path"),
    ] = Path("."),
    json_flag: Annotated[
        bool,
        typer.Option("--json", help="Output as JSON"),
    ] = False,
)

Source from the content-addressed store, hash-verified

113
114@project_app.command("version")
115def project_version(
116 ctx: typer.Context,
117 path: Annotated[
118 Path,
119 typer.Argument(help="Unity project path"),
120 ] = Path("."),
121 json_flag: Annotated[
122 bool,
123 typer.Option("--json", help="Output as JSON"),
124 ] = False,
125) -> None:
126 """Show Unity version for project."""
127 from unity_cli.exceptions import ProjectVersionError
128 from unity_cli.hub.project import ProjectVersion
129
130 context: CLIContext = ctx.obj
131 try:
132 version = ProjectVersion.from_file(path)
133
134 if _should_json(context, json_flag):
135 print_json({"version": version.version, "revision": version.revision})
136 else:
137 print_line(f"Unity: [cyan]{version.version}[/cyan]")
138 if version.revision:
139 print_line(f"Revision: [dim]{version.revision}[/dim]")
140
141 except ProjectVersionError as e:
142 _handle_error(e)
143
144
145@project_app.command("packages")

Callers

nothing calls this directly

Calls 5

_should_jsonFunction · 0.90
print_jsonFunction · 0.90
print_lineFunction · 0.90
_handle_errorFunction · 0.90
from_fileMethod · 0.45

Tested by

no test coverage detected