Created
March 5, 2014 10:41
-
-
Save andrijac/9364950 to your computer and use it in GitHub Desktop.
Node.js console boilerplate
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 readline = require('readline'); | |
var toArray = function(){return Array.prototype.slice.call(arguments[0]);} | |
var log = function() { | |
var arr = toArray(arguments).map(function(v) { | |
// debugger; | |
return v + ''; | |
}); | |
console.log(arr.join(" ")); | |
} | |
var blank = function(){log("");} | |
var wl = function(){log.apply(this, toArray(arguments)); blank();} | |
blank(); | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
if (process.argv.length < 3) { | |
process.argv.forEach(function (e) { | |
wl(e); | |
}); | |
} | |
rl.question("", function(){rl.close();}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment