Skip to content

Honor --dry-run on all draft-mutating commands #15

@renezander030

Description

@renezander030

Summary

--dry-run is currently honored only by translate and export --batch. Every other draft-mutating command (add-text, cut, apply-template, speed, volume, trim, shift, keyframe, ...) ignores it and writes to disk. A global --dry-run that computes the change and prints the normal JSON result without writing would make the CLI safe to explore and much friendlier for LLM/agent callers (preview, then commit).

What to do

  • Make --dry-run (already parsed into flags.dryRun) suppress the on-disk write for every command that mutates a draft, while still emitting the usual JSON result so callers see what would change.
  • Cleanest path: gate the write in saveDraft() — all write commands funnel through it (34 call sites). Thread the dry-run state in (a module-level flag set from flags.dryRun, or an explicit option) and skip both the writeFileSync and the .bak write when set.
  • Add --dry-run to the global-flags block in the HELP constant.

Acceptance

  • capcut speed <project> <id> 2 --dry-run (and the other write commands) print the same JSON result as a real run but leave the file and its .bak untouched.
  • Existing translate / export --batch dry-run behavior is unchanged.
  • A test under test/ asserting the draft file is byte-identical after a --dry-run write.
  • Documented in README.md / docs/.

Pointers (verified against master)

  • The flag is already parsed: parseFlags() sets flags.dryRun on --dry-run (src/index.ts).
  • All writes go through saveDraft(filePath, draft) in src/draft.ts (34 call sites in src/index.ts); it also writes ${filePath}.bak.
  • out(data, flags) is the JSON emitter — keep emitting in dry-run mode.
  • Zero runtime dependencies (Node >= 18).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions