-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.js
More file actions
40 lines (33 loc) · 698 Bytes
/
cli.js
File metadata and controls
40 lines (33 loc) · 698 Bytes
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
var proxey = require('./proxey.js');
var args = process.argv;
var fs = require('fs');
function CLI (data) {
this.data = data || null;
};
CLI.prototype.loadFile = function (callback) {
var configFilename = 'proxey.json';
fs.readFile(__dirname + '/' + configFilename, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
this.data = JSON.parse(data);
if (callback) {
callback();
}
});
};
CLI.prototype.run = function () {
proxey.run(this.data);
};
var cli = new CLI();
if (args.length <= 2) {
cli.loadFile(function () {
cli.run();
});
} else {
var userArgs = args.slice(2);
cli.loadArgs(userArgs, function () {
cli.run();
});
}