node-flags
v0.1.9
Published
Simple module for parsing double-dash flags in node.
Downloads
2,260
Readme
node-flags
Simple module for parsing double-dash flags in node.
Install
$ npm install node-flags
Usage
This module parses double-dash flags from node's process.argv object. Flags are specified when running a node script. For example:
$ node server --foo=bar
To use, require in the module:
var flags = require("node-flags");
var foo = flags.get('foo');
The flags.get()
method parses flags with the following behavior:
- A flag with the value of
FALSE
,false
,TRUE
, ortrue
is parsed as a boolean. - A flag with the value of
0
or1
is parsed as a number. - A flag that is exists, but has no value is parsed as boolean true.
- A flag that does not exist is parsed as boolean false.
- A flag that exists and has any other value is parsed as a string.
Test
$ npm test
Changelog
As of 0.1.6, flags with values of 0 or 1 are parsed as numbers.