Created
May 13, 2016 09:40
-
-
Save netsi1964/6417c5151ef6fc05f25d9427fa4ffbcb to your computer and use it in GitHub Desktop.
Simple Node.js module to get process arguments
This file contains hidden or 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
| function getArgs() { | |
| var argv = process.argv.join(' '); | |
| var result = {}; // reset | |
| for ( | |
| argv = argv.split(/\s*\B[\/-]+([\w-]+)[\s=]*/), | |
| i = 1; item = argv[i++]; result[item] = argv[i++] | |
| ); | |
| return result; | |
| } | |
| module.exports = getArgs(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy'n'pasted and modified to my needs from: https://github.com/tnhu/arg/blob/master/arg.js