-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (35 loc) · 1.15 KB
/
index.js
File metadata and controls
41 lines (35 loc) · 1.15 KB
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
var util = require('util'), fs = require('fs'), path = require('path'), util = require('util');
var cli = require('cli').enable('daemon'), color = require("ansi-color").set;
var $proxy = require('./proxy.js');
/**
* Parse the command line arguments and daemonize as necessary;
*
* @api public
*/
exports.parse = function () {
cli.enable('version');
cli.setApp($proxy.name, $proxy.version);
var options = cli.parse( {
test : [ 't', 'Test location', 'string' ],
install : [ 'i', 'Install config file and init.d script' ]
});
if (options.test) {
var destination = require('./processor.js').test(options.test);
console.log(color('\t' + destination.hostname + ":" + destination.port, "green"));
} else if (options.install) {
console.log(color('\tinstalling...', "green"));
var installer = require('./installer.js');
installer.install(function (error) {
if (error) {
console.log(color('\t' + error, "red"));
}
console.log(color('\tdone', "green"));
});
} else {
process.title = "nodast";
cli.main(function (args, options) {
$proxy.start();
});
}
};
exports.start = $proxy.start;