feat: global --dry-run and restore command (#15, #16)#25
Merged
Conversation
#15 — every draft-mutating command now honors --dry-run. Gated in saveDraft (the single write choke point), so all ~35 write commands are covered at once: the on-disk write and the .bak snapshot are skipped, while out() stamps the JSON result with "dryRun":true so callers can tell a preview from a commit. translate / export --batch keep their own dry-run paths. #16 — `capcut restore <project>` copies <draft>.bak back over the draft to undo the last write. Single-step (one backup generation kept); dies with a clear message when no .bak exists; honors --dry-run. Adds test/dry-run.test.mjs and test/restore.test.mjs (5 tests). README + CHANGELOG updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #15. Closes #16.
#15 — global
--dry-runEvery draft-mutating command now honors
--dry-run. Gated at the single write choke point (saveDraft), so all ~35 write commands are covered at once: the on-disk write and the.baksnapshot are skipped, whileout()stamps the JSON result with"dryRun":trueso agents/scripts can distinguish a preview from a commit.translate/export --batchkeep their existing dry-run behavior (they write through their own paths, notsaveDraft).#16 —
restorecapcut restore <project>copies<draft>.bakback over the draft to undo the last write. Single-step (one backup generation kept); dies with a clear message when no.bakexists; honors--dry-run.Tests & docs
test/dry-run.test.mjs+test/restore.test.mjs— 5 tests covering: byte-identical draft after dry-run, no.bakin dry-run, real write still mutates, restore round-trip, no-.bakexits non-zero, dry-run restore is a no-op.#17 (
prune) is intentionally left for a follow-up — see its scoping comment.🤖 Generated with Claude Code