Created
December 27, 2014 13:44
-
-
Save mistakster/8045ab603c9328f5b97d to your computer and use it in GitHub Desktop.
Simple parser for command line arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var args = process.argv | |
.filter(function (p, i) { | |
return i > 1 && p.indexOf('--') == 0 && p.indexOf('=') > 0; | |
}) | |
.reduce(function (out, p) { | |
var parts = p.match(/^--([^=]+)=(.*)$/); | |
out[parts[1]] = parts[2]; | |
return out; | |
}, {}); | |
module.exports = exports = args; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This module returns object which contains all CLI parameters matched following pattern:
--key=value
.Example: