-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·78 lines (71 loc) · 2.06 KB
/
index.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
#! /usr/bin/env node
// Require configs
const configBlizzardAPI = require('config').get('blizzard');
// Require module libraries
const _ = require('lodash');
const Yargs = require('yargs');
// Require specific files to load
const Pkg = require('./package.json');
const Data = require('./src/data');
/*let struct = [
{ name: 'achievements.id', call: '_.has' },
{ name: 'achievements.title', call: '_.has' }
];*/
/*_.mixin({
findNestedObject: (object, data, struct) => {
// Before do anything, check if parameter struct is ok, no point in doing extra work
_.forEach(struct, item => {
if (!item.name && (!item.criteria || !_.isFunction(item.call))) {
throwError('Invalid structure!!!')
}
});
// To avoid destroying the original array, meaning if we need to go back to the original
// data set at any point of time, lets map it to a new set.
_.map(object, (value, key) => {
if (_.isPlainObject(value)) {
_.findNestedObject(value)
} else if (_.isArray(value) && !_.isEmpty(value)) {
console.log('arraySize: ' + value.length);
_.map(value, item => {
_.findNestedObject(item)
})
} else {
_.forEach(struct, item => {
console.log('key: ' + key + '; value: ' + value);
});
}
});
}
});*/
module.exports = Yargs
.command({
command: 'data <key> [value]',
desc: 'Set a config variable',
builder: (yargs) => yargs.default('value', 'false'),
handler: (argv) => {
switch(argv.key) {
case 'all':
Data.run();
break;
case 'community':
case 'comm':
Data.run('community');
break;
case 'community-oauth-profile':
case 'comm-oauth-prof':
Data.run('community-oauth-profile');
break;
case 'game-data':
Data.run('game-data');
break;
default:
console.log('Command not found...')
}
}
})
.version(Pkg.version)
.alias('version', 'v')
.help('help')
.alias('help', 'h')
.demandCommand()
.argv;