-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpast.js
29 lines (22 loc) · 840 Bytes
/
past.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
const { pastGames } = 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 PastCommand extends Command {
async run() {
const { flags } = this.parse(PastCommand);
try {
const gamesData = await runWithSpinner(pastGames);
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!'
);
}
}
}
PastCommand.description = `Retrieves all the past games for the "Copa Libertadores"`;
PastCommand.flags = gamesOptions;
module.exports = PastCommand;