node-flags

0.1.9 • Public • Published

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, or true is parsed as a boolean.
  • A flag with the value of 0 or 1 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.

Readme

Keywords

Package Sidebar

Install

npm i node-flags

Weekly Downloads

153

Version

0.1.9

License

MIT

Last publish

Collaborators

  • erikuix