Created
April 1, 2014 23:07
-
-
Save sorensen/9924923 to your computer and use it in GitHub Desktop.
Get argv input
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 argv = process.argv | |
, slice = Array.prototype.slice | |
function getArg() { | |
var args = slice.call(arguments) | |
for (var i = 0; i < args.length; i++) { | |
var name = args[i] | |
, idx = argv.indexOf(name) | |
if (~idx) { | |
if (argv[idx + 1]) return argv[idx + 1] | |
return true | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment