List Assembly Definitions (.asmdef) in Assets/.
(
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,
)
| 356 | |
| 357 | @project_app.command("assemblies") |
| 358 | def project_assemblies( |
| 359 | ctx: typer.Context, |
| 360 | path: Annotated[ |
| 361 | Path, |
| 362 | typer.Argument(help="Unity project path"), |
| 363 | ] = Path("."), |
| 364 | json_flag: Annotated[ |
| 365 | bool, |
| 366 | typer.Option("--json", help="Output as JSON"), |
| 367 | ] = False, |
| 368 | ) -> None: |
| 369 | """List Assembly Definitions (.asmdef) in Assets/.""" |
| 370 | context: CLIContext = ctx.obj |
| 371 | from unity_cli.hub.project import find_assembly_definitions, is_unity_project |
| 372 | |
| 373 | path = path.resolve() |
| 374 | |
| 375 | if not is_unity_project(path): |
| 376 | print_error(f"Not a valid Unity project: {path}", "INVALID_PROJECT") |
| 377 | raise typer.Exit(ExitCode.USAGE_ERROR) from None |
| 378 | |
| 379 | assemblies = find_assembly_definitions(path) |
| 380 | |
| 381 | if _should_json(context, json_flag): |
| 382 | print_json( |
| 383 | [ |
| 384 | { |
| 385 | "name": asm.name, |
| 386 | "path": str(asm.path.relative_to(path)), |
| 387 | "references": asm.references, |
| 388 | "include_platforms": asm.include_platforms, |
| 389 | "exclude_platforms": asm.exclude_platforms, |
| 390 | "allow_unsafe": asm.allow_unsafe, |
| 391 | "auto_referenced": asm.auto_referenced, |
| 392 | } |
| 393 | for asm in assemblies |
| 394 | ] |
| 395 | ) |
| 396 | else: |
| 397 | if not assemblies: |
| 398 | print_line("[dim]No Assembly Definitions found in Assets/[/dim]") |
| 399 | return |
| 400 | |
| 401 | if is_no_color(): |
| 402 | rows = [ |
| 403 | [asm.name, str(asm.path.relative_to(path)), str(len(asm.references)), "yes" if asm.allow_unsafe else ""] |
| 404 | for asm in assemblies |
| 405 | ] |
| 406 | _print_plain_table(["Name", "Path", "Refs", "Unsafe"], rows, f"Assembly Definitions ({len(assemblies)})") |
| 407 | else: |
| 408 | from rich.table import Table |
| 409 | |
| 410 | table = Table(title=f"Assembly Definitions ({len(assemblies)})") |
| 411 | table.add_column("Name", style="cyan") |
| 412 | table.add_column("Path", style="dim") |
| 413 | table.add_column("Refs", justify="right") |
| 414 | table.add_column("Unsafe") |
| 415 | for asm in assemblies: |
nothing calls this directly
no test coverage detected