ditto.cli¶
CLI command implementations for snapshot management.
ditto CLI — snapshot management for pytest-ditto.
Subcommands
run Run pytest, reporting any snapshot activity at the end. update Re-run pytest with --ditto-update to regenerate snapshots. prune Re-run pytest with --ditto-prune to remove stale snapshots. lock Rebuild ditto.lock from current snapshots. verify Fail if the backend has drifted from ditto.lock (read-only). list List all snapshot files under a path. clean Delete all .ditto/ directories under a path. status Show aggregate statistics for snapshots under a path. recorders List all registered recorder plugins. doctor Run health checks on the ditto installation and plugins. lint Check snapshot files for naming, format, and integrity issues. stats Show per-directory snapshot usage breakdown.
gather_stats(entries, ext_map)
¶
Aggregate snapshot statistics from a list of ManifestEntry items.
Source code in ditto/cli.py
render_stats(stats, console)
¶
Render a SnapshotStats value as a Rich panel.
Source code in ditto/cli.py
cli()
¶
cmd_run(pytest_args)
¶
Run pytest, reporting any snapshot activity at the end.
Any extra arguments are passed directly to pytest.
Examples: ditto run ditto run tests/ci/ ditto run tests/ci/ -k test_foo
Source code in ditto/cli.py
cmd_update(pytest_args)
¶
Re-run pytest with --ditto-update to regenerate snapshots.
Any extra arguments are passed directly to pytest.
Examples: ditto update ditto update tests/ci/ ditto update tests/ci/ -k test_foo
Source code in ditto/cli.py
cmd_prune(check, pytest_args)
¶
Re-run pytest to delete snapshots not in ditto.lock.
With --check, report what would be pruned without deleting anything. Any extra arguments are passed directly to pytest.
Examples: ditto prune ditto prune --check ditto prune tests/ci/
Source code in ditto/cli.py
cmd_lock(pytest_args)
¶
Rebuild ditto.lock from current snapshots (full run; values unchanged).
Must run the whole suite: passing positional path/nodeid args narrows the run
and is refused, because a narrowed rebuild can truncate entries for files it
did not collect. Configure the suite's scope via testpaths in pyproject/ini
instead.
Examples: ditto lock
Source code in ditto/cli.py
cmd_verify(pytest_args)
¶
Fail if the backend has drifted from ditto.lock (read-only).
Examples: ditto verify ditto verify tests/ci/
Source code in ditto/cli.py
cmd_list(path, live)
¶
List all snapshot files under PATH (default: current directory).
By default reads local snapshots from disk and remote snapshots from ditto.lock (credential-free); pass --live to read live backends.
Examples: ditto list ditto list tests/ci/
Source code in ditto/cli.py
cmd_clean(path, yes)
¶
Delete all .ditto/ directories under PATH.
Shows a preview of what will be deleted and requires confirmation unless --yes is passed.
Examples: ditto clean ditto clean --yes ditto clean tests/ci/ --yes
Source code in ditto/cli.py
cmd_status(path, live)
¶
Show aggregate statistics for snapshots under PATH.
By default aggregates local snapshots from disk and remote snapshots from ditto.lock (credential-free); pass --live to read live backends.
Examples: ditto status ditto status tests/ci/
Source code in ditto/cli.py
cmd_recorders()
¶
List all registered recorder plugins.
Examples: ditto recorders
Source code in ditto/cli.py
cmd_doctor()
¶
Run health checks: plugin loading, pytest availability.
Examples: ditto doctor
Source code in ditto/cli.py
cmd_lint(path, live)
¶
Check snapshot files for naming issues, unknown formats, and empty files.
By default lints local snapshots from disk and remote snapshots from ditto.lock (credential-free); pass --live to read live backends.
Examples: ditto lint ditto lint tests/ci/
Source code in ditto/cli.py
cmd_stats(path, live)
¶
Show per-directory snapshot usage breakdown.
By default breaks down local snapshots from disk and remote snapshots from ditto.lock (credential-free); pass --live to read live backends.
Examples: ditto stats ditto stats tests/ci/