Skip to content

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

Merged
MarshallOfSound merged 1 commit intomainfrom
claude/replace-commander-builtin-EHwhE
Apr 22, 2026
Merged

refactor: replace commander with native Node.js parseArgs#416
MarshallOfSound merged 1 commit 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
@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

Copy link
Copy Markdown
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

LGTM, got a merge conflict tho

Comment thread bin/asar.mjs
}
}

function printHelp() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having to re-implement --help is a bit annoying but alas

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 96d51a3 to 1d9844a Compare April 22, 2026 00:58
@MarshallOfSound MarshallOfSound merged commit 42b25d0 into main Apr 22, 2026
7 checks passed
@MarshallOfSound MarshallOfSound deleted the claude/replace-commander-builtin-EHwhE branch April 22, 2026 01:02
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.

3 participants