Reputation: 784
I am writing some code in JavaScript and running it using the command line using the command node filename.js
. I want the user to enter input values on the command line and use these values for further process and output.
Upvotes: 0
Views: 2573
Reputation: 196
Use prompts npm package
npm install --save prompts
const prompts = require('prompts');
const questions = [
{
type: 'text',
name: 'dish',
message: 'Do you like pizza?'
},
{
type: prev => prev == 'pizza' ? 'text' : null,
name: 'topping',
message: 'Name a topping'
}
];
(async () => {
const response = await prompts(questions);
})();
Upvotes: 1