UNPKG

1.8 kBJavaScriptView Raw
1import Yam from 'yam';
2import fido from '../';
3import chrono from 'chrono-node';
4
5var cfg = []; // eslint-disable-line
6var fromDate = null; // eslint-disable-line
7
8const config = new Yam('fido', {
9 primary: require('user-home'),
10 secondary: process.cwd(),
11});
12
13const argv = require('yargs')
14 .usage('Usage: fido')
15 .option('i', {
16 alias: 'id',
17 demand: false,
18 describe: 'The podcast id to query (single numeric value)',
19 })
20 .option('n', {
21 alias: 'name',
22 demand: false,
23 describe: 'The name of the podcast to query',
24 type: 'string',
25 })
26 .option('c', {
27 alias: 'countries',
28 demand: false,
29 describe: 'The countries to query (space separated)',
30 type: 'array',
31 })
32 .option('p', {
33 alias: 'pages',
34 demand: false,
35 describe: 'The number of pages to fetch (page size is 50)',
36 })
37 .option('f', {
38 alias: 'from',
39 demand: false,
40 describe: 'Natural language date from which point on reviews should be fetched',
41 type: 'string',
42 })
43 .option('l', {
44 alias: 'last',
45 describe: 'Get the natural language relative date from the config file that represents the start time of the last podcast episode. The value should be under a top level key called last_episode_date. Example: Last Monday 5pm',
46 type: 'boolean',
47 })
48 .help('h')
49 .alias('h', 'help')
50 .argv;
51
52if (typeof argv.id !== 'undefined') {
53 cfg.push({
54 id: argv.id,
55 name: argv.name,
56 countries: argv.countries,
57 });
58} else {
59 cfg = config.get('podcasts');
60}
61
62if (typeof argv.from !== 'undefined') {
63 fromDate = chrono.parseDate(argv.from);
64}
65
66if (argv.last === true) {
67 const lastEpiDate = config.get('last_episode_date');
68
69 if (typeof lastEpiDate !== undefined) {
70 fromDate = chrono.parseDate(lastEpiDate);
71 }
72}
73
74fido(cfg, argv.pages, fromDate);