Skip to content

CLI → Replace commander with node:util parseArgs - #40

Merged
mpsq merged 3 commits into
mainfrom
remove-commander
Oct 8, 2026
Merged

mpsq merged 3 commits into
mainfrom
remove-commander

Conversation

@mpsq

@mpsq mpsq commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Removes commander, our only dependency besides @team-plain/graphql, and parses arguments with Node's built-in node:util parseArgs.


Note

Low Risk
CLI-only refactor with no API or auth changes; behavior is locked in by expanded tests, with minor risk of subtle flag/positional parsing differences versus commander.

Overview
Drops the commander dependency and implements CLI routing and parsing with Node’s built-in node:util parseArgs, leaving @team-plain/graphql as the only runtime dependency.

index-url and index-sitemap are driven by a small COMMANDS map with hand-written top-level and per-command help, plus --version / --help. Subcommand parsing keeps prior behavior for --labelTypeIds / -l (including values after -l until the next flag) and adds explicit errors for unknown commands, bad arity, and invalid options.

Integration tests cover repeated label flags, validation failures, help output, and version printing. A changeset records a patch release for @team-plain/cli.

Reviewed by Cursor Bugbot for commit 93e6115. Bugbot is set up for automated code reviews on this repo. Configure here.

Drops the commander dependency. Help, version and the variadic
-l/--labelTypeIds option keep working as before.

Co-Authored-By: Claude <noreply@anthropic.com>
@mpsq
mpsq requested a review from a team as a code owner October 8, 2026 09:09
mpsq and others added 2 commits October 8, 2026 10:10
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] CLI argument parsing reimplemented without external dependency.

The PR appears safe to merge, with a non-blocking regression in the help command.

Fix All in Claude CodeFindings

  1. P2 Help command stops working ▶
Fix with agent prompt
### Issue 1
src/index.ts:160-163
Running `plain help` or `plain help index-url` now exits with “unknown command 'help'” instead of showing help. The previous `commander` setup supplied these commands automatically. The new routing only accepts flags and names in `COMMANDS`, so existing help calls reach `usageError`. Restore support for `help` and `help <command>`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1) · Last reviewed commit: "Merge branch 'main' into remove-commande..." · Reviewed by Greptile

Comment thread src/index.ts
Comment on lines +160 to +163
} else if (Object.hasOwn(COMMANDS, name)) {
await index(name, COMMANDS[name], args);
} else {
usageError(`unknown command '${name}'`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Help command stops working

Running plain help or plain help index-url now exits with “unknown command 'help'” instead of showing help. The previous commander setup supplied these commands automatically. The new routing only accepts flags and names in COMMANDS, so existing help calls reach usageError. Restore support for help and help <command>.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/index.ts
Line: 160-163

Comment:
**Help command stops working**

Running `plain help` or `plain help index-url` now exits with “unknown command 'help'” instead of showing help. The previous `commander` setup supplied these commands automatically. The new routing only accepts flags and names in `COMMANDS`, so existing help calls reach `usageError`. Restore support for `help` and `help <command>`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Cursor

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is fine IMO.

@revett revett left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice!

@mpsq
mpsq merged commit 1b74762 into main Oct 8, 2026
11 checks passed
@mpsq
mpsq deleted the remove-commander branch October 8, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants