The easiest way to do this, IMHO will show the "questions" to the user and is waiting for an answer. These questions can always be the same (a hint like "→") or, possibly, another (if you want, for example, to request some variables).
You can use stdio to show these questions. This is a module that simplifies standard I / O control, and one of its main functions is exactly what you want:
var stdio = require('stdio'); stdio.question('What is your name?', function (err, name) { stdio.question('Are you male or female?', ['male', 'female'], function (err, sex) { console.log('Your name is "%s". You are "%s"', name, sex); }); });
If you run the previous code, you will see something like this:
What is your name?: John Are you male or female? [male/female]: female Your name is "john". You are "female"
stdio includes support for retries if you specify a group of possible answers. Otherwise, users will be able to write whatever they want.
PD: I'm the creator of stdio . stdio

source share