1.简介

常见的交互式命令行用户界面的集合。

https://www.npmjs.com/package/inquirer

2、示例(输入和单选)

var inquirer = require('inquirer');

var questions = [
    {
        type: 'input',
        name: 'name',
        message: "What's your name"
    },
    {
        type: 'list',
        name: 'size',
        message: 'What size do you need?',
        choices: ['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro']
    }
];

inquirer.prompt(questions).then(answers => {
    console.log(JSON.stringify(answers, null, '  '));
});

输出:

{
  "name": "meng",
  "size": "Large"
}