Skip to content

refactor: replace commander with native Node.js parseArgs#416

Open
MarshallOfSound wants to merge 2 commits intomainfrom
claude/replace-commander-builtin-EHwhE
Open

refactor: replace commander with native Node.js parseArgs#416
MarshallOfSound wants to merge 2 commits intomainfrom
claude/replace-commander-builtin-EHwhE

Conversation

@MarshallOfSound
Copy link
Copy Markdown
Member

Summary

Replaced the commander CLI framework dependency with Node.js's built-in parseArgs utility from the node:util module. This eliminates an external dependency while maintaining all existing CLI functionality.

Key Changes

  • Removed commander dependency from package.json
  • Replaced commander import with parseArgs from node:util
  • Refactored CLI structure from fluent command builder pattern to a declarative commands object
  • Implemented custom argument parsing and validation logic using parseArgs
  • Added custom help text generation (printHelp() and printCommandHelp()) to replace commander's built-in help
  • Converted command handlers to use positional arguments and parsed options
  • Maintained all existing commands: pack, list, extract-file, extract, and integrity-digest
  • Preserved command aliases and all option flags with their original behavior

Implementation Details

  • Commands are now defined as a configuration object with metadata (aliases, usage, description, args, options, action)
  • Manual argument parsing and validation replaces commander's automatic handling
  • Help system is custom-built to match the original output format
  • Error handling for missing required arguments and invalid commands is explicit
  • All command actions properly handle both synchronous and asynchronous operations via Promise.resolve()

https://claude.ai/code/session_018MZgp8bWBzCGeFy3SaCjtC

@MarshallOfSound MarshallOfSound requested a review from a team as a code owner March 24, 2026 08:18
@MarshallOfSound MarshallOfSound changed the title Replace commander with native Node.js parseArgs refactor: replace commander with native Node.js parseArgs Mar 24, 2026
Removes the commander dependency in favor of Node's built-in
util.parseArgs for CLI argument parsing. Since the minimum supported
Node version is 22.12.0, parseArgs is fully available and stable.

This reduces the dependency footprint while maintaining the same CLI
interface including subcommands, aliases, options, and help output.
@MarshallOfSound MarshallOfSound force-pushed the claude/replace-commander-builtin-EHwhE branch from aef0754 to fceaa8d Compare April 19, 2026 10:50
@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 19, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

The previous lockfile regeneration accidentally re-resolved several
transitive dependencies (esbuild, vite, electron, etc.) instead of only
removing commander. Restore main's resolutions so the diff only drops
the commander entry.
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