Skip to content

feat: refactor comfy-pr CLI to yargs with cpr alias#193

Merged
snomiao merged 1 commit into
mainfrom
sno-cpr
Apr 5, 2026
Merged

feat: refactor comfy-pr CLI to yargs with cpr alias#193
snomiao merged 1 commit into
mainfrom
sno-cpr

Conversation

@snomiao

@snomiao snomiao commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactor src/cli.ts from zx argv to yargs with proper subcommand handling
  • Add cpr as a bin alias for comfy-pr in package.json
  • Running cpr with no args shows help with available subcommands
  • cpr create [repos..] replaces the old positional args pattern
  • cpr create --repolist repos.txt and REPO=... cpr create still work

Test plan

  • cpr shows help by default
  • cpr --help shows usage with examples
  • Typecheck passes

🤖 Generated with Claude Code

- Replace zx argv with yargs for proper subcommand handling
- Add `cpr` as a bin alias for `comfy-pr`
- Show help with available subcommands by default
- `cpr create [repos..]` replaces the old positional args pattern

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 5, 2026 09:23
@vercel

vercel Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comfy-pr Ready Ready Preview, Comment Apr 5, 2026 9:25am

Request Review

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​napi-rs/​cli@​3.6.0921008593100

View full report

@snomiao
snomiao merged commit 48760c0 into main Apr 5, 2026
7 checks passed
@snomiao
snomiao deleted the sno-cpr branch April 5, 2026 09:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the comfy-pr CLI to use yargs with a create subcommand and adds cpr as an additional executable alias.

Changes:

  • Replaced zx argv parsing with yargs-based subcommand parsing (create [repos..], --repolist, REPO=...).
  • Added help/usage examples and stricter CLI argument handling.
  • Added cpr as a bin alias in package.json.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/cli.ts Migrates CLI parsing to yargs, introduces create subcommand, and repo-resolution logic.
package.json Adds cpr as a new bin alias pointing to the same CLI entrypoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli.ts
Comment on lines 2 to +4
import { readFile } from "fs/promises";
import { argv, $ as zx } from "zx";
import { hideBin } from "yargs/helpers";
import yargs from "yargs/yargs";

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/cli.ts now imports yargs at runtime, but package.json does not list yargs as a direct dependency. Relying on it being hoisted as a transitive dependency is not reliable and can break the published CLI. Add yargs (and keep it in dependencies, not devDependencies) so the bin works consistently.

Copilot uses AI. Check for mistakes.
Comment thread src/cli.ts
Comment on lines +68 to +72
.example("$0 create url1 url2 url3", "Create PRs for multiple repos")
.example("REPO=https://github.com/owner/repo $0 create", "Create PR via env variable")
.demandCommand(1, "Please specify a command. Run with --help to see available commands.")
.strict()
.help()

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says running cpr with no args shows help by default, but .demandCommand(1, ...) treats missing commands as an error (non-zero exit) and prints an error message. If the intended behavior is a normal help display, add a default $0 command (or similar) that calls showHelp()/returns 0, and reserve demandCommand/failure messaging for genuinely invalid input.

Copilot uses AI. Check for mistakes.
Comment thread src/cli.ts
}

const cli = yargs(hideBin(process.argv))
.scriptName("cpr")

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.scriptName("cpr") hard-codes the displayed binary name in help/usage. Since package.json exposes both comfy-pr and cpr, this will show cpr even when invoked as comfy-pr, which is confusing for users following existing docs. Consider deriving the script name from process.argv[1] (basename) or omitting scriptName() so yargs uses the actual invoked name.

Suggested change
.scriptName("cpr")

Copilot uses AI. Check for mistakes.
@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants