Skip to content

Add shell completions command (bash/zsh/fish) #8

@renezander030

Description

@renezander030

Summary

capcut-cli ships ~35 subcommands (info, tracks, materials, segments, texts, create, build, add-video, add-audio, add-text, add-sfx, caption, import-srt, import-ass, keyframe, transition, mask, text-anim, migrate, lint, translate, doctor, enums, version, templates, export, audio-fade, bubble-text, add-filter, add-cover, mix-mode, chroma, …). A completions command that prints a shell completion script would make the CLI much nicer to use interactively — and it's a self-contained, zero-dependency addition.

What to do

Add a new command capcut completions <bash|zsh|fish> that prints a completion script to stdout for the chosen shell. The script should complete:

  • the subcommand names, and
  • the global flags --json and --jianying.

Users install it with e.g.:

capcut completions zsh > ~/.zsh/completions/_capcut
# or
capcut completions bash >> ~/.bashrc

Pointers (verified against current master)

  • The CLI is TypeScript, single entry point src/index.ts, compiled to dist/. There is no src/commands/ directory — commands are dispatched inline in src/index.ts via a chain of if (cmd === "…") checks.
  • Derive the command list from that dispatch chain (don't hardcode a second copy that can drift). The cleanest approach: lift the command names into an exported const COMMANDS = [...] as const in src/index.ts, use it both for dispatch and for the completion output.
  • Global flags are read with parseGlobalFlag(args, "--json") (see top of src/index.ts); --jianying is the namespace switch.
  • Zero runtime dependencies (dependencies: {}, Node >= 18) — keep it dependency-free.
  • Add a test under test/ following the existing pattern (test/*.test.mjs, helpers in test/helpers/).
  • Document it in README.md and docs/.

Good first issue — three independent PRs

bash, zsh, and fish can each be a separate PR — pick one shell to start. Each is small, self-contained, and a great way to learn the codebase. Happy to review quickly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions