-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·40 lines (31 loc) · 1.11 KB
/
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
33
34
35
36
37
38
39
#!/usr/bin/env node
//Kudos: https://github.com/DatanewsOrg/google-news-js
//https://github.com/sindresorhus/terminal-link
const readline = require("readline");
const shell = require("shelljs");
const program = require("commander");
const chalk = require("chalk");
const boxen = require("boxen");
const { showHeadlines } = require('./lib/search');
const { runPrompt, TOPICS } = require('./lib/questions');
const HEADLINES_RSS = 'https://news.google.com/news/rss';
const TOPICS_RSS = 'https://news.google.com/news/rss/headlines/section/topic/';
const GEO_RSS = 'https://news.google.com/news/rss/headlines/section/geo/';
const SEARCH_RSS = 'https://news.google.com/rss/search?q=';
program.version('1.0.0');
program.option('-n, --headlines <num>', 'Show top n headlines');
program.parse(process.argv);
if(program.headlines) {
showHeadlines(program.headlines);
return
}
const handleEscKeypress = () => {
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => {
if (chunk === '\u001b') {
process.exit(0);
}
});
};
handleEscKeypress();
runPrompt();