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

Function snapshot_diff

unity_cli/cli/commands/uitree.py:730–754  ·  view source on GitHub ↗

Compare current UI tree against a saved snapshot. Examples: u uitree snapshot diff -p "PanelSettings" --name baseline

(
    ctx: typer.Context,
    panel: Annotated[str, typer.Option("--panel", "-p", help="Panel name")],
    name: Annotated[str, typer.Option("--name", help="Baseline snapshot name")],
    json_flag: Annotated[bool, typer.Option("--json", help="Output as JSON")] = False,
)

Source from the content-addressed store, hash-verified

728@snapshot_app.command("diff")
729@handle_cli_errors
730def snapshot_diff(
731 ctx: typer.Context,
732 panel: Annotated[str, typer.Option("--panel", "-p", help="Panel name")],
733 name: Annotated[str, typer.Option("--name", help="Baseline snapshot name")],
734 json_flag: Annotated[bool, typer.Option("--json", help="Output as JSON")] = False,
735) -> None:
736 """Compare current UI tree against a saved snapshot.
737
738 Examples:
739 u uitree snapshot diff -p "PanelSettings" --name baseline
740 """
741 from unity_cli.api.uitree_snapshot import SnapshotStore
742
743 context: CLIContext = ctx.obj
744 current = context.client.uitree.dump(panel=panel, format="json")
745 try:
746 result = SnapshotStore().diff(name, current)
747 except FileNotFoundError:
748 print_line(f"Snapshot '{name}' not found")
749 raise typer.Exit(1) from None
750
751 if _should_json(context, json_flag):
752 print_json(result, None)
753 else:
754 _print_diff_result(result)
755
756
757def _print_diff_result(result: dict[str, Any]) -> None:

Callers

nothing calls this directly

Calls 8

SnapshotStoreClass · 0.90
print_lineFunction · 0.90
_should_jsonFunction · 0.90
print_jsonFunction · 0.90
_print_diff_resultFunction · 0.85
dumpMethod · 0.80
diffMethod · 0.80
ExitMethod · 0.80

Tested by

no test coverage detected