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,
)
| 728 | @snapshot_app.command("diff") |
| 729 | @handle_cli_errors |
| 730 | def 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 | |
| 757 | def _print_diff_result(result: dict[str, Any]) -> None: |
nothing calls this directly
no test coverage detected