forked from marklagendijk/node-toogoodtogo-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (27 loc) · 882 Bytes
/
index.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
#!/usr/bin/env node
const { pollFavoriteBusinesses } = require('./lib/poller');
const { notifyIfChanged } = require('./lib/notifier');
const { editConfig, resetConfig, configPath } = require('./lib/config');
const argv = require('yargs')
.usage('Usage: toogoodtogo-watcher <command>')
.command('config', 'Edit the config file.')
.command('config-reset', 'Reset the config to the default values.')
.command('config-path', 'Show the path of the config file.')
.command('watch', 'Watch your favourite busininesses for changes.')
.demandCommand()
.argv;
switch (argv._[0]) {
case 'config':
editConfig();
break;
case 'config-reset':
resetConfig();
break;
case 'config-path':
configPath();
break;
case 'watch':
pollFavoriteBusinesses()
.subscribe(businesses => notifyIfChanged(businesses), console.error);
break;
}