Skip to content

Instantly share code, notes, and snippets.

@troufster
Created October 14, 2010 18:34
Show Gist options
  • Save troufster/626744 to your computer and use it in GitHub Desktop.
Save troufster/626744 to your computer and use it in GitHub Desktop.
var args = process.argv.slice(2);
var exargs = {
'-a' : function(val) {
if(!val) return;
console.log('Arg a does stuff with ' + val);
},
'-b' : function() {
console.log('arg b in da house');
},
'-c' : function() {
console.log('arg c represent');
}
};
for (var arg in exargs) {
var argindex = args.indexOf(arg);
if(argindex != -1) {
exargs[arg](args[argindex+1]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment