1.0.1 • Published 7 years ago
inquirer-level-select v1.0.1
层级结构数据终端选择交互命令
Example
- 具有层级结构数据传入格式
{
"result": [
{
"name": "channel",
"title": "渠道",
"type": 0,
"children": [
{
"name ": "order",
"title": "订单",
"children": [
{
"name": "list",
"title": "列表",
"children": [],
"type": 1
}
],
"type": 0
},
{
"name": "manage",
"title": "管理",
"children": [
],
"type": 0
},
{
"name": "manage2",
"title": "管理2",
"children": [
],
"type": 1
}
]
},
{
"name": "distribu",
"title": "分销",
"type": 0,
"children": []
}
]
}
- Prompt的注册调用
const inquirer = require("inquirer")
const { result } = require("./config")
const { del: Prompt } = require('./index')
inquirer.registerPrompt('level', Prompt)
inquirer.prompt([
{
type: "level",
name: "pathArr",
message: "请选择",
basePath: "./模块",
data: result
}
]).then(res => {
console.log(res)
})
1.0.1
7 years ago