1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | var path = require('path');
|
26 | var fs = require('fs');
|
27 | var Fiber = require('fibers');
|
28 |
|
29 | TRAINJS_LIB_PATH = path.join(path.dirname(fs.realpathSync(__filename)), '../');
|
30 | var info_param = {};
|
31 |
|
32 |
|
33 | function checkinfo () {
|
34 | info_param.trainjs_version = require(TRAINJS_LIB_PATH + 'package.json').version;
|
35 | info_param.node_version = process.version.substr(1);
|
36 | }
|
37 |
|
38 | Fiber(function() {
|
39 | checkinfo();
|
40 | if (process.argv[2] == "server" || process.argv[2] == "s") {
|
41 | require('./train_server.js')();
|
42 | } else if (process.argv[2] == "new") {
|
43 | require('./train_new.js')(info_param);
|
44 | } else if (process.argv[2] == "-h" || process.argv[2] == "--help") {
|
45 | fs.readFile(path.dirname(fs.realpathSync(__filename)) + '/train_help', function (err, data) {
|
46 | if (err) throw err;
|
47 | console.log(data.toString());
|
48 | });
|
49 | } else if (process.argv[2] == "-v" || process.argv[2] == "--version") {
|
50 | console.log("trainjs " + info_param.trainjs_version);
|
51 | } else if (process.argv[2] == "generate" || process.argv[2] == "g") {
|
52 | if (process.argv[3] == "scaffold")
|
53 | require('./train_generate_scaffold.js')();
|
54 | else if (process.argv[3] == "controller")
|
55 | require('./train_generate_controller.js')();
|
56 | else if (process.argv[3] == "model")
|
57 | require('./train_generate_model.js')();
|
58 | else if (process.argv[3] == "database")
|
59 | require('./train_generate_database.js')();
|
60 | else if (process.argv[3] == "service")
|
61 | require('./train_generate_service.js')();
|
62 | }
|
63 | }).run();
|