Skip to content

Instantly share code, notes, and snippets.

@Estecka
Last active October 20, 2020 07:38
Show Gist options
  • Save Estecka/c349f3a383b27027fd19955c9ae7755e to your computer and use it in GitHub Desktop.
Save Estecka/c349f3a383b27027fd19955c9ae7755e to your computer and use it in GitHub Desktop.
Tiny Javascript Command Line Interface for NodeJS
console.log("Welcome, master");
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: true
});
rl.on('line', function(line){
if (line == "exit")
return rl.close();
try {
var r = eval(line);
console.log(r);
} catch (e) {
console.log(e);
}
})
function load (module){
global[module] = require("./"+module+"/index.js");
return module;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment