-
Notifications
You must be signed in to change notification settings - Fork 12
/
matcher.js
39 lines (33 loc) · 1.03 KB
/
matcher.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
// eslint-disable-next-line new-cap
const vorpal = new require('vorpal')();
const _commands = require('./src/matcher-commands.js');
const envVars = require('./.env_vars.json');
vorpal
.delimiter('matcher-cli > ')
.show();
if (envVars.ENV === 'PROD') {
_commands = envVars.COMMAND_ENDPOINT;
}
const {commands} = _commands;
vorpal
.command('matcher <query>', `
!USAGE COMMANDS!
update: Updates matcher environment.
clear: Clears console, and exits.
matches: Outputs pairs of matched key-points.
corners: Outputs all eligible match points.
`)
.action(vorpalify);
async function vorpalify(args) {
const {query} = args;
// eslint-disable-next-line no-unused-vars
const summoner = await commands.summoner;
if (eval(`commands.${query}`) !== undefined) {
eval(`commands.${query}()`);
} else if (eval(`summoner.${query}`)) {
console.log(eval(`summoner.${query}`));
} else {
error(`Invalid command: "${query}", exiting...\n`);
process.exit();
}
}