-
Notifications
You must be signed in to change notification settings - Fork 5
/
options.js
93 lines (86 loc) · 2.25 KB
/
options.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
var args = require('args'),
cached = {},
options = args.Options.parse([
{
name: 'include',
shortName: 'i',
help: 'Comma seperated db and design docs to include'
},
{
name: 'exclude',
shortName: 'e',
help: 'Comma seperated db and design docs to exclude'
},
{
name: 'dashboard',
shortName: 'd',
help: 'optional dashboard db name to follow changes.'
},
{
name: "web",
shortName: "w",
type: 'bool',
defaultValue: false,
help: 'Enable local http server adding /_garden proxy in couch'
},
{
name: 'host',
shortName: 'h',
help: 'The host name to bind the http server to.',
defaultValue: 'localhost'
},
{
name: 'port',
type: 'int',
shortName: 'p',
help: 'The port to bind the http server to.',
defaultValue: 25984
},
{
name: 'upnp',
type: 'bool',
help: 'Use upnp opening port on firewall, using the public ip',
defaultValue: false
},
{
name: 'user',
help: 'The username passed to node modules'
},
{
name: 'pass',
help: 'The password passed to node modules'
},
{
name: 'time',
shortName: 't',
type: 'int',
help: 'Polling interval (seconds).',
defaultValue: 30
},
{
name: 'stdinpass',
type: 'bool',
help: 'read a single line from stdin, used for couch password',
defaultValue: false
},
{
name: 'logdir',
shortName: 'l',
help: 'specify relative or absolute directory where logs will be written',
defaultValue: 'logs'
}
]);
exports.set_options = function(arg_array) {
cached = args.parser(arg_array, { start: 0 }).parse(options);
if (cached.user && (!cached.pass && !cached.stdinpass)) throw Error('A password must be provided with the user option');
if (!cached.user && cached.pass) throw Error('A user must be provided with the password option');
};
exports.get_options = function() {
return cached;
};
exports.get_options_value = function(name) {
return cached[name];
};
exports.getHelp = function() {
return options.getHelp();
};