Skip to content

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

Open
MarshallOfSound wants to merge 1 commit intomainfrom
claude/replace-commander-builtin-EHwhE
Open

refactor: replace commander with native Node.js parseArgs#416
MarshallOfSound wants to merge 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

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 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
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