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

Function component_list

unity_cli/cli/commands/component.py:26–49  ·  view source on GitHub ↗

Enumerate every Component attached to a GameObject. Example: u component list -t Player

(
    ctx: typer.Context,
    target: Annotated[str | None, typer.Option("--target", "-t", help="Target GameObject name")] = None,
    target_id: Annotated[int | None, typer.Option("--target-id", help="Target GameObject ID")] = None,
    json_flag: Annotated[
        bool,
        typer.Option("--json", help="Output as JSON"),
    ] = False,
)

Source from the content-addressed store, hash-verified

24@component_app.command("list")
25@handle_cli_errors
26def component_list(
27 ctx: typer.Context,
28 target: Annotated[str | None, typer.Option("--target", "-t", help="Target GameObject name")] = None,
29 target_id: Annotated[int | None, typer.Option("--target-id", help="Target GameObject ID")] = None,
30 json_flag: Annotated[
31 bool,
32 typer.Option("--json", help="Output as JSON"),
33 ] = False,
34) -> None:
35 """Enumerate every Component attached to a GameObject.
36
37 Example:
38 u component list -t Player
39 """
40 context: CLIContext = ctx.obj
41
42 if not target and target_id is None:
43 _exit_usage("--target or --target-id required", "u component list")
44
45 result = context.client.component.list(target=target, target_id=target_id)
46 if _should_json(context, json_flag):
47 print_json(result)
48 else:
49 print_components_table(result.get("components", []))
50
51
52@component_app.command("inspect")

Callers

nothing calls this directly

Calls 6

_exit_usageFunction · 0.90
_should_jsonFunction · 0.90
print_jsonFunction · 0.90
print_components_tableFunction · 0.90
listMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected