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

Function menu_list

unity_cli/cli/commands/menu.py:60–101  ·  view source on GitHub ↗

List Unity menu-bar entries (built-in + custom [MenuItem]). Useful for discovering which paths 'u menu exec' can invoke. Examples: u menu list # All menu items u menu list -f Tools # Items containing 'Tools' u menu list -f "Windo

(
    ctx: typer.Context,
    filter_text: Annotated[
        str | None,
        typer.Option("--filter", "-f", help="Filter menu items (case-insensitive)"),
    ] = None,
    limit: Annotated[
        int,
        typer.Option("--limit", "-l", help="Maximum items to return"),
    ] = 100,
    json_flag: Annotated[
        bool,
        typer.Option("--json", help="Output as JSON"),
    ] = False,
)

Source from the content-addressed store, hash-verified

58
59@menu_app.command("list")
60def menu_list(
61 ctx: typer.Context,
62 filter_text: Annotated[
63 str | None,
64 typer.Option("--filter", "-f", help="Filter menu items (case-insensitive)"),
65 ] = None,
66 limit: Annotated[
67 int,
68 typer.Option("--limit", "-l", help="Maximum items to return"),
69 ] = 100,
70 json_flag: Annotated[
71 bool,
72 typer.Option("--json", help="Output as JSON"),
73 ] = False,
74) -> None:
75 """List Unity menu-bar entries (built-in + custom [MenuItem]).
76
77 Useful for discovering which paths 'u menu exec' can invoke.
78
79 Examples:
80 u menu list # All menu items
81 u menu list -f Tools # Items containing 'Tools'
82 u menu list -f "Window/Analysis" # Narrow to a submenu
83 """
84 context: CLIContext = ctx.obj
85 try:
86 result = context.client.menu.list(filter_text=filter_text, limit=limit)
87 if _should_json(context, json_flag):
88 print_json(result)
89 else:
90 items = result.get("items", [])
91 if is_no_color():
92 for item in items:
93 path = item.get("path", str(item)) if isinstance(item, dict) else str(item)
94 print_plain_item(path)
95 else:
96 print_line(f"[bold]Menu Items ({len(items)})[/bold]")
97 for item in items:
98 path = item.get("path", str(item)) if isinstance(item, dict) else str(item)
99 print_line(f" {escape(path)}")
100 except UnityCLIError as e:
101 _handle_error(e)
102
103
104@menu_app.command("context")

Callers

nothing calls this directly

Calls 8

_should_jsonFunction · 0.90
print_jsonFunction · 0.90
is_no_colorFunction · 0.90
print_plain_itemFunction · 0.90
print_lineFunction · 0.90
_handle_errorFunction · 0.90
listMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected