-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.js
42 lines (32 loc) · 1007 Bytes
/
generate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env node
var program = require('commander');
var pJson = require('./package.json');
var createComponent = require('./utils/create-component');
var deleteComponent = require('./utils/delete-component');
const args = process.argv.slice(2)
program.version(pJson.version)
program.on('--help', function () {
console.log(' Examples:');
console.log('');
console.log(' generate c <name-component>');
console.log(' generate d <name-component>');
console.log('');
});
program
.command('c <name>')
.description('generate component named <name>')
.action(function (name) {
createComponent(name);
});
program
.command('d <name>')
.description('delete component named <name>')
.action(function (name) {
deleteComponent(name);
});
program.parse(process.argv);
if (!program.version)
console.log(program.version())
if (!args.length || (args[0] !== 'c' && args[0] !== 'd'))
program.outputHelp();
// console.log(args[0])