talira

minimist

Minimal command-line argument parser for Node.js

open sourceMITfree

minimist is a small Node.js library that parses command-line arguments into an object: short and long flags, grouped short flags, --key=value and --no-flag forms, with non-option arguments collected in an array. Options treat named arguments as strings or booleans, map aliases, set defaults, stop at the first non-option, split off everything after --, and call a function for unknown options. It's the core of optimist's argument parser without the extras. For a full CLI framework with commands and help text, yargs is the larger option.

Problems it solves

  • parse command-line flags in a small Node.js script
  • turn process.argv into an object of options
  • read --key=value arguments in Node without a big CLI framework

Features

  • parses short, long, grouped and --no- flags into an object
  • string, boolean, alias and default options
  • stop at the first non-option, or split off arguments after --
  • callback for unknown options
  • CommonJS and ES module imports

Alternatives

The same job

These do what minimist does.

  1. yargs Parse command-line arguments and build CLIs in Node.js
  2. meow Small helper for building Node.js command-line apps
  3. Commander.js The complete solution for Node.js command-line interfaces
  4. oclif Salesforce's open CLI framework for building Node.js command-line tools
  5. Inquirer.js Interactive command-line prompts for Node.js

Compare minimist with the top 3