-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathng-amt.js
executable file
·91 lines (74 loc) · 1.97 KB
/
ng-amt.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
#!/usr/bin/env node
"use strict";
// General.
const fs = require('fs-extra');
const path = require('path');
const _ = require('underscore');
const J = require('JSUS').JSUS;
// Commander.
/////////////
let program = require('./lib/core/program');
program.parse(process.argv);
// Winston logger.
//////////////////
let logger = require('./lib/core/logger')(program);
// Load and check config.
/////////////////////////
let cfg = require('./lib/core/config')(program);
if (!cfg) return;
// VORPAL COMMANDS
//////////////////
let vorpal = require('./lib/core/vorpal');
// DEFAULT ACTION (from program)
////////////////////////////////
var codes;
let opts = program.opts();
if (opts.inputCodesFile || opts.resultsFile || opts.game) {
codes = require('./lib/core/codes');
if (opts.inputCodesFile) {
opts.path = opts.inputCodesFile;
codes.loadInputCodes(opts);
}
if (opts.resultsFile) {
opts.path = opts.resultsFile;
codes.loadResults(opts);
}
}
var args;
args = {};
if (opts.getLastHITId) args.getLastHITId = true;
if (opts.getQualificationTypeId) args.getQualificationTypeId = true;
if (args.getLastHITId || opts.getQualificationTypeId) opts.connect = true;
// Async operations needs to be completed before the first prompt.
if (opts.connect) {
require('./lib/core/api').connect(args, function() {
if (opts.game) {
loadGame(startVorpal);
}
else {
startVorpal();
}
});
}
else if (opts.game) {
loadGame(startVorpal);
}
else {
startVorpal();
}
// Helper methods.
function startVorpal() {
vorpal
.delimiter('ng-amt$')
.show();
}
function loadGame(cb) {
// TODO: fix parameter naming.
opts.path = opts.game;
// The limit parameter is the next after the game.
let indexLimit = opts.rawArgs.indexOf(opts.game) + 1;
opts.limit = opts.rawArgs[indexLimit];
codes.loadGame(opts, cb);
}
// Do we need to export it?
// module.exports.stuff = stuff;