Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions packages/utils/src/core/inquirer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,32 @@ import inquirer from 'inquirer'
*/

/**
* 终端选择交互
* 终端选择交互,单选
*/
export async function promptList(choiceList: string[], message?: string): Promise<string> {
return (await inquirer.prompt([
{
type: 'list',
name: 'app',
message: message ?? '选择repo模块...',
message: message ?? '请选择模块...',
choices: choiceList,
},
])
).app
}

/**
* 终端交互选择,多选
*/
export async function promptCheckBox(choiceList: string[], message?: string) {
return (await inquirer.prompt([
{
type: 'checkbox',
name: 'app',
message: message ?? '请选择模块...',
choices: choiceList,
loop: false,
},
])
).app
}
File renamed without changes.
6 changes: 6 additions & 0 deletions packages/utils/test/inquirer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { promptCheckBox } from '@142vip/utils';

(async () => {
const app = await promptCheckBox([1, 2, 3, 4, 5, 6, 7, 8, 9])
console.log(111, app)
})()
Loading