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.
- yargs Parse command-line arguments and build CLIs in Node.js
- meow Small helper for building Node.js command-line apps
- Commander.js The complete solution for Node.js command-line interfaces
- oclif Salesforce's open CLI framework for building Node.js command-line tools
- Inquirer.js Interactive command-line prompts for Node.js