Inquirer 交互式命令行

Posted mengfangui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Inquirer 交互式命令行相关的知识,希望对你有一定的参考价值。

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"
}

 

以上是关于Inquirer 交互式命令行的主要内容,如果未能解决你的问题,请参考以下文章

webpack 入门 -

手把手教你使用nodejs编写cli(命令行)

NPM 模块收集

vue-cli 原理分析

inquirerjs

linux打开终端如何启动scala,如何在终端下运行Scala代码片段?