ifweb
Version:
后台管理系统脚手架
49 lines (43 loc) • 1.35 kB
JavaScript
console.log('~~~~~ peach-cli working ~~~~~')
const commander = require('commander')
const chalk = require('chalk')
var figlet = require('figlet')
commander
.command('create <app-name>')
.description('create a new project')
.option('-f, --force', 'overwrite target directory if it exit')
.action((name, options) => {
console.log('name:', name, 'option:', options)
require('../command/init.js')(name, options)
})
.version(`v${require('../package.json').version}`)
.usage('<command> [option]')
// 配置 config 命令
commander
.command('config [value]')
.description('inspect and modify the config')
.option('-g, --get <path>', 'get value from option')
.option('-s, --set <path> <value>')
.option('-d, --delete <path>', 'delete option from config')
.action((value, options) => {
console.log(value, options)
})
commander.on('--help', () => {
// 使用 figlet 绘制 Logo
console.log(
'\r\n' +
figlet.textSync('FWEB', {
font: 'Ghost',
horizontalLayout: 'default',
verticalLayout: 'default',
width: 80,
whitespaceBreak: true
})
)
// 新增说明信息
console.log(
`\r\nRun ${chalk.cyan(`ifweb <command> --help`)} show details\r\n`
)
})
commander.parse(process.argv)