-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall.js
35 lines (26 loc) · 918 Bytes
/
all.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
const { allGames } = require('../../fetchers/games');
const runWithSpinner = require('../../utils/run-with-spinner');
const formatOutput = require('../../utils/format-output');
const gamesOptions = require('../../utils/games-options');
const { Command } = require('@oclif/command');
class AllCommand extends Command {
async run() {
const { flags } = this.parse(AllCommand);
try {
const gamesData = await runWithSpinner(allGames);
gamesData.forEach(data => this.log(formatOutput(data, flags)));
} catch (e) {
console.error(e);
this.error(
'An error occurred while retrieving data, please try again or report it!'
);
}
}
}
AllCommand.description = `Retrieves all the games for the "Copa Libertadores"
Color coding:
- green means it has already been played
- red means it is a future game
`;
AllCommand.flags = gamesOptions;
module.exports = AllCommand;