Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created May 13, 2016 09:40
Show Gist options
  • Select an option

  • Save netsi1964/6417c5151ef6fc05f25d9427fa4ffbcb to your computer and use it in GitHub Desktop.

Select an option

Save netsi1964/6417c5151ef6fc05f25d9427fa4ffbcb to your computer and use it in GitHub Desktop.
Simple Node.js module to get process arguments
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();
@netsi1964
Copy link
Copy Markdown
Author

Copy'n'pasted and modified to my needs from: https://github.com/tnhu/arg/blob/master/arg.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment