-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
48 lines (43 loc) · 1003 Bytes
/
cli.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
args = process.argv.slice(2);
exports.port = false;
exports.portNum = 8080;
exports.connect = false;
exports.connectAddr = '0.0.0.0';
exports.connectPort = 8080;
exports.testBroadcast = false;
exports.monitor = false;
for (var i = 0;i <args.length; i++)
{
if (args[i+1])
{
switch(args[i])
{
case 'port':
exports.portNum = (args[i+1]+"").search("^\\d+&") != 1 ? args[i+1] : 8080;
exports.port = (args[i+1]+"").search("^\\d+&") != 1 ? true : false ;
break;
case 'name':
exports.name = args[i+1];
}
}
if (args[i+2] && args[i+1])
{
switch(args[i])
{
case 'connect':
exports.connectAddr = (args[i+1]+"").search("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$") != 1 ? args[i+1] : '0.0.0.0';
exports.connectPort = (args[i+2]+"").search("^\\d+&") != 1 ? args[i+2] : 8080;
exports.connect = true;
break;
}
}
switch (args[i])
{
case 'broadcast':
exports.testBroadcast = true;
break;
case 'monitor':
exports.monitor = true;
break;
}
}