Use argparse for Node.js CLI argument parsing
masterargparse is a Node.js port of Python's argparse module, providing a robust way to parse command-line arguments, including support for sub-commands.
Because this is a JavaScript port, note the following differences from the original Python implementation:
- Options instead of keyword arguments: Pass configuration via an options object, e.g.,
new ArgumentParser({ description: 'example' }). - String-typed names for types: Since JS lacks Python's native types like
intorfloat, use string literals for thetypeparameter, such as{ type: 'int' }. - Format specifiers: The
%rformat specifier utilizesrequire('util').inspect()for representation.
const { ArgumentParser } = require('argparse')