Say I'm creating a simple CLI. I want to use native node readline module to take in some input from user at prompt. I thought of this :
var prompt = chalk.bold.magenta;
var info = {};
rl.question(prompt('Thing One : '), function(args) {
info.one = args;
rl.question(prompt('Thing Two : '), function(args) {
info.two = args;
rl.question(prompt('Thing Three : '), function(args) {
info.three = parseInt(args);
rl.close();
runSomeOtherModuleNow();
})
})
});
This does seem to work in a way I'd like, but this seems like a bad approach. I'd much prefer a flatter code than a pyramid like this.
Any suggestions are welcome!