streaver/libertadores-cli

View on GitHub
src/commands/games/all.js

Summary

Maintainability
A
3 hrs
Test Coverage
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;