node.js:Inquirer.js接收命令行交互输入

在这里插入图片描述
A collection of common interactive command line user interfaces.

文档:

安装

npm i inquirer

代码示例

import inquirer from "inquirer";

(async () => {
    
    
  let input = await inquirer.prompt([
    {
    
    
      type: "list",
      name: "type",
      choices: ["money", "working", "exit"],
      message: "please choose doing",
      suffix: ":",
    },
  ]);

  console.log(input);
  //  { type: 'working' }
})();

猜你喜欢

转载自blog.csdn.net/mouday/article/details/126035172