Skip to content

Add top-level --version / -v flag (print installed CLI version) #10

@renezander030

Description

@renezander030

Summary

There's no top-level capcut --version / capcut -v to print the installed CLI version. Note that the existing capcut version subcommand does something different — it inspects a draft's CapCut/JianYing support status, not the package version. A standard --version flag is what users and bug reports expect.

What to do

In src/index.ts, handle --version / -v as a global flag before command dispatch (the command is read as positional[0] after flag parsing). Print the version from package.json and exit 0.

  • Resolve package.json relative to the compiled entry point. The file already computes a cliDir (used to locate templates/_init); reuse that to read ../package.json so it works from dist/.
  • Add a -v, --version line to the HELP constant near the top of src/index.ts.

Example:

$ capcut --version
0.6.0

Acceptance

  • capcut --version and capcut -v both print the package version and exit 0.
  • Doesn't collide with the existing version subcommand (that keeps its current draft-support behavior).
  • Add a test under test/ following the existing *.test.mjs pattern (helpers in test/helpers/).
  • Update README.md / docs/ usage.

Pointers (verified against master)

  • Single entry point src/index.ts (TypeScript → dist/); no src/commands/ dir.
  • HELP constant ~line 81; command dispatch reads const cmd = positional[0].
  • cliDir is already used for bundled-template resolution — reuse for package.json.
  • Zero runtime dependencies (Node >= 18) — keep it dependency-free.

Good first issue — tiny, self-contained, and high-value for bug reports.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions