text-kkt-day2
v1.0.0
Published
```JavaScript // #!/usr/bin/env node const program = require('commander') const inquirer = require('inquirer')
Downloads
2
Readme
Day2练习
// #!/usr/bin/env node
const program = require('commander')
const inquirer = require('inquirer')
const initAction = () => {
inquirer.prompt([{
name: "user_name",
type: "input",
message: "你叫什么名字? "
}, {
name: 'user_age',
type: "number",
message: "你今年几岁了呀?"
}, {
name: 'like_vegetables',
type: 'confirm',
message: "你喜欢吃蔬菜吗?"
}, {
name: "vegetables_kind",
type: "checkbox",
message: "你都喜欢吃以下哪几种蔬菜?",
choices: ['黄瓜', '西红柿', '芹菜', '菜椒', '卷心菜', '红萝卜', '土豆']
}]).then(answers => {
console.log(answers)
})
}
program.command('init').description('创建项目').action(initAction)
program.parse(program.argv)//解析命令