Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Migration of API from v1 to v2 #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions cmds/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ exports.command = 'config';

exports.desc = 'Change configuration and defaults';

exports.builder = function builder(yargs) {
return yargs
.usage('Usage: sudo $0 config')
.example('sudo $0 config')
.argv;
};
exports.builder = yargs => yargs
.usage('Usage: sudo $0 config')
.example('sudo $0 config')
.argv;

exports.handler = function handler(yargs) {
exports.handler = (yargs) => {
/** Get all the options set for `config` command */
const configs = yargs;

Expand Down
52 changes: 25 additions & 27 deletions cmds/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,31 @@ const { footballRequest } = requests;
exports.command = 'fixtures';
exports.desc = 'Get upcoming and past fixtures of a league and team';

exports.builder = function builder(yargs) {
return yargs
.usage('Usage: $0 fixtures [options]')
.alias('d', 'days')
.describe('d', 'Number of days from today')
.number('d')
.alias('l', 'league')
.describe('l', 'League')
.string('l')
.alias('t', 'team')
.describe('t', 'Team name or substring of it')
.string('t')
.alias('n', 'next')
.describe('n', 'Next or upcoming matches')
.boolean('n')
.alias('j', 'json')
.describe('j', 'JSON output file name')
.string('j')
.alias('c', 'csv')
.describe('c', 'CSV output file name')
.string('c')
.alias('o', 'dir')
.describe('o', 'Output directory for files')
.string('o')
.example('$0 fixtures -l PL -d 5 -t "Manchester United" -n')
.argv;
};
exports.builder = yargs => yargs
.usage('Usage: $0 fixtures [options]')
.alias('d', 'days')
.describe('d', 'Number of days from today')
.number('d')
.alias('l', 'league')
.describe('l', 'League')
.string('l')
.alias('t', 'team')
.describe('t', 'Team name or substring of it')
.string('t')
.alias('n', 'next')
.describe('n', 'Next or upcoming matches')
.boolean('n')
.alias('j', 'json')
.describe('j', 'JSON output file name')
.string('j')
.alias('c', 'csv')
.describe('c', 'CSV output file name')
.string('c')
.alias('o', 'dir')
.describe('o', 'Output directory for files')
.string('o')
.example('$0 fixtures -l PL -d 5 -t "Manchester United" -n')
.argv;

exports.handler = (yargs) => {
/** Get all the options set for `fixtures` command */
Expand Down
18 changes: 8 additions & 10 deletions cmds/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ const { LEAGUE_IDS_URL } = URLS;
exports.command = 'lists';
exports.desc = 'List of codes of various competitions';

exports.builder = function builder(yargs) {
return yargs
.usage('Usage: sudo $0 lists [options]')
.alias('r', 'refresh')
.describe('r', 'Refresh league ids')
.boolean('r')
.example('sudo $0 lists -r')
.argv;
};
exports.builder = yargs => yargs
.usage('Usage: sudo $0 lists [options]')
.alias('r', 'refresh')
.describe('r', 'Refresh league ids')
.boolean('r')
.example('sudo $0 lists -r')
.argv;

exports.handler = function handler(yargs) {
exports.handler = (yargs) => {
/** Get all the options set for `lists` command */
const lists = yargs;

Expand Down
42 changes: 20 additions & 22 deletions cmds/scores.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,27 @@ exports.command = 'scores';

exports.desc = 'Get scores of past and live fixtures';

exports.builder = function builder(yargs) {
return yargs
.usage('Usage: $0 scores [options]')
.alias('l', 'live')
.describe('l', 'Live scores')
.boolean('l')
.alias('t', 'team')
.describe('t', 'Select team')
.string('t')
.alias('j', 'json')
.describe('j', 'Output results as JSON file')
.string('j')
.alias('c', 'csv')
.describe('c', 'Output results as CSV file')
.string('c')
.alias('o', 'dir')
.describe('o', 'Output directory for files')
.string('o')
.example('$0 scores -t "Manchester United" -l')
.argv;
};
exports.builder = yargs => yargs
.usage('Usage: $0 scores [options]')
.alias('l', 'live')
.describe('l', 'Live scores')
.boolean('l')
.alias('t', 'team')
.describe('t', 'Select team')
.string('t')
.alias('j', 'json')
.describe('j', 'Output results as JSON file')
.string('j')
.alias('c', 'csv')
.describe('c', 'Output results as CSV file')
.string('c')
.alias('o', 'dir')
.describe('o', 'Output directory for files')
.string('o')
.example('$0 scores -t "Manchester United" -l')
.argv;

exports.handler = function handler(yargs) {
exports.handler = (yargs) => {
/** Get all the options set for `scores` command */
const scores = yargs;

Expand Down
38 changes: 18 additions & 20 deletions cmds/standings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,24 @@ const { footballRequest } = requests;
exports.command = 'standings';
exports.desc = 'Get standings of particular league';

exports.builder = function builder(yargs) {
return yargs
.usage('Usage: $0 standings [options]')
.alias('l', 'league')
.describe('l', 'League to be searched')
.demand('l')
.alias('j', 'json')
.describe('j', 'Output results as JSON file')
.string('j')
.alias('c', 'csv')
.describe('c', 'Output results as CSV file')
.string('c')
.alias('o', 'dir')
.describe('o', 'Output directory for files')
.string('o')
.example('$0 standings -l PL')
.argv;
};

exports.handler = function handler(yargs) {
exports.builder = yargs => yargs
.usage('Usage: $0 standings [options]')
.alias('l', 'league')
.describe('l', 'League to be searched')
.demand('l')
.alias('j', 'json')
.describe('j', 'Output results as JSON file')
.string('j')
.alias('c', 'csv')
.describe('c', 'Output results as CSV file')
.string('c')
.alias('o', 'dir')
.describe('o', 'Output directory for files')
.string('o')
.example('$0 standings -l PL')
.argv;

exports.handler = (yargs) => {
/** Get all the options set for `standings` command */
const standings = yargs;

Expand Down
2 changes: 1 addition & 1 deletion constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const API_URL = 'http://api.football-data.org/v1/';
const API_URL = 'http://api.football-data.org/v2/';
const BUGS_URL = 'https://github.com/ManrajGrover/football-cli/issues';
const LEAGUE_IDS_URL = 'https://api.github.com/repos/ManrajGrover/football-cli/contents/leagueIds.json';

Expand Down
86 changes: 31 additions & 55 deletions leagueIds.json
Original file line number Diff line number Diff line change
@@ -1,74 +1,50 @@
{
"BSA": {
"id": 444,
"caption": "Campeonato Brasileiro da Série A"
"id": 2013,
"caption": "Brazil Série A"
},
"PL": {
"id": 445,
"caption": "Premier League 2017/18"
"id": 2021,
"caption": "English Premier League"
},
"ELC": {
"id": 446,
"caption": "Championship 2017/18"
"EC": {
"id": 2016,
"caption": "English Championship"
},
"EL1": {
"id": 447,
"caption": "League One 2017/18"
"EUC": {
"id": 2018,
"caption": "European Championship"
},
"EL2": {
"id": 448,
"caption": "League Two 2017/18"
},
"DED": {
"id": 449,
"caption": "Eredivisie 2017/18"
"CL": {
"id": 2001,
"caption": "UEFA Champions League"
},
"FL1": {
"id": 450,
"caption": "Ligue 1 2017/18"
},
"FL2": {
"id": 451,
"caption": "Ligue 2 2017/18"
},
"BL1": {
"id": 452,
"caption": "1. Bundesliga 2017/18"
"id": 2015,
"caption": "French Ligue 1"
},
"BL2": {
"id": 453,
"caption": "2. Bundesliga 2017/18"
"GB": {
"id": 2002,
"caption": "German Bundesliga"
},
"PD": {
"id": 455,
"caption": "Primera Division 2017"
"ISA": {
"id": 2019,
"caption": "Italy Serie A"
},
"SA": {
"id": 456,
"caption": "Serie A 2017/18"
"NE": {
"id": 2003,
"caption": "Netherlands Eredivisie"
},
"PPL": {
"id": 457,
"caption": "Primeira Liga 2017/18"
},
"DFB": {
"id": 458,
"caption": "DFB-Pokal 2017/18"
},
"SB": {
"id": 459,
"caption": "Serie B 2017/18"
},
"CL": {
"id": 464,
"caption": "Champions League 2017/18"
"id": 2017,
"caption": "Portugal Primeira Liga"
},
"AAL": {
"id": 466,
"caption": "Australian A-League"
"SPD": {
"id": 2014,
"caption": "Spain Primera Division"
},
"WC": {
"id": 467,
"caption": "World Cup"
"id": 2000,
"caption": "FIFA World Cup"
}
}