args

Command line arguments parser

args is command line arguments parser for node.js

Instead of trying to deal with all your complex cases, args provides a toolset to help you with arguments parsing.

Supported syntax for options: --option=value, --option value, -abc, -abc value

For boolean flags, true value can be omitted, i.g. -f true can be replaced with -f (and --flag true with --flag also).

  • name
  • shortName
  • key
  • type
  • isList
  • enumItems
  • custom
    • check
    • parse
    • tryParse
    • get
  • help
var args = require('args');
 
var options = args.Options.parse([
    {
        name: 'option',
        shortName: 'o',
        type: 'int',
        help: 'some option'
    }
]);
 
options.getHelp();
 
var parser = new args.Parser('node app.js --option 11'.split(' '), 2);
parser.parse(options);
var parsed = parser.prepareResult();
console.log(parsed); // {option: 11}