-
Notifications
You must be signed in to change notification settings - Fork 13
/
kranium.js
executable file
·98 lines (82 loc) · 1.81 KB
/
kranium.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env node
var nomnom = require('nomnom'),
parser = nomnom(),
path = require('path'),
utils = require('./lib/utils'),
fs = require('fs');
(function(){
var defaults = {
port: 8128,
ip: '127.0.0.1',
test: false,
debug: false,
backbone: false
};
function autoload(str){
return function(opts){
var fn = require(str);
//fn.apply(fn, arguments);
new fn(opts);
};
}
function cwdToTiRoot(){
var cwd, found = false;
while(!path.existsSync(process.cwd() + '/tiapp.xml') && (process.chdir('../'), (cwd = process.cwd()) !== '/'));
return cwd !== '/';
}
if(!cwdToTiRoot()){
return "No Titanium project found, KTHXBAI".err();
}
parser.globalOpts({
version: {
string: '-v, --version',
help: 'print version and exit',
callback: function() {
return JSON.parse(fs.readFileSync(require.main.filename.replace(/[^\/]+$/, 'package.json'))).version;
}
}
});
parser.command('init').opts({
debug: {
string: '-d, --debug',
help: 'set app to debug mode',
"default": defaults.debug
},
test: {
string: '-t, --test',
help: 'activate app tests',
"default": defaults.test
},
backbone: {
string: '-b, --backbone',
help: 'activate backbone for app',
"default": defaults.backbone
},
ip: {
string: '-i, --ip',
help: 'ip to bind to'
},
port: {
string: '-p, --port',
help: 'port to bind to',
"default": defaults.port
},
}).callback(autoload('./lib/command/init'));
parser.command('watch').opts({
debug: {
string: '-d, --debug',
help: 'set app to debug mode',
"default": defaults.debug
},
ip: {
string: '-i, --ip',
help: 'ip to bind to'
},
port: {
string: '-p, --port',
help: 'port to bind to',
"default": defaults.port
},
}).callback(autoload('./lib/command/watch'));
parser.parseArgs();
})();