-
Notifications
You must be signed in to change notification settings - Fork 1
/
eventmonitoring.js
executable file
·74 lines (62 loc) · 2.13 KB
/
eventmonitoring.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
#!/usr/bin/env node
var yargs = require('yargs');
var Q = require('q');
var pkg = require('./package.json');
var config = require('./src/lib/config.js');
var show = require('./src/show.js');
var cache = require('./src/cache.js');
var dump = require('./src/dump.js');
var login = require('./src/login.js');
var report = require('./src/report.js');
var statics = require('./src/lib/statics.js');
var utils = require('./src/utils.js');
global.config = { url: undefined };
global.logger = require('./src/lib/logger.js');
global.printer = require('./src/lib/printer.js');
var OPTIONS = {
env: statics.CONFIG.env,
username: statics.CONFIG.username,
password: statics.CONFIG.password,
token: statics.CONFIG.token,
sandbox: statics.CONFIG.sandbox,
solenopsis: statics.CONFIG.solenopsis,
cache: statics.CONFIG.cache,
interval: statics.CONFIG.interval,
latest: statics.CONFIG.latest,
start: statics.CONFIG.start,
end: statics.CONFIG.end,
date: statics.CONFIG.date,
helper: statics.CONFIG.helper,
logfile: statics.CONFIG.logfile,
logformat: statics.CONFIG.logformat,
debug: statics.CONFIG.debug
};
var CONFLICTS = {
env: [ 'username', 'password', 'token' ],
solenopsis: [ 'username', 'password', 'token' ]
};
/**
* Runs the script
* @returns {Promise} A promise for when it's been run
*/
var run = function () {
var deferred = Q.defer();
yargs.usage('$0 <cmd> [args]')
.options(OPTIONS)
.conflicts(CONFLICTS)
.version(pkg.version)
.command('show [type]', 'Show user information', show.config, show.run)
.command('cache [action]', 'Interact with cache', cache.config, cache.run)
.command('dump', 'Dump data', dump.config, dump.run)
.command('login [type]', 'Login information', login.config, login.run)
.command('report [type]', 'Display a report', report.config, report.run)
.command('utils [type]', 'Utility methods', utils.config, utils.run)
.argv;
deferred.resolve();
return deferred.promise;
};
config.loadConfig()
.then(run)
.catch(function (error) {
global.logger.error(error);
});