-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
40 lines (32 loc) · 923 Bytes
/
index.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
#! /usr/bin/env node
'use strict';
const chalk = require('chalk');
const program = require('commander');
const _package = require('./package.json');
// Get the function to create controllers.
const createControllers = require('./core/init');
let { c, blockname } = '';
// Set the command.
program
.option('<make>', 'generate fields')
.version('1.0.0')
.action((cmd) => {
c = cmd;
});
// Parse the arguments.
program.parse(process.argv);
// if no command were provided.
if (typeof c === "undefined") {
console.log(chalk.red(`No command were provided, please run '${_package.name} --help' command`));
process.exit(1);
}
// run the script.
switch (c) {
case 'make':
// Generate file.
createControllers.generateBlocks();
break;
// Default msg.
default:
console.log(chalk.red(`Invalid command, please run '${_package.name} --help' command`));
}