-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
executable file
·50 lines (40 loc) · 1.24 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
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
'use strict';
var path = require('path'),
program = require('commander'),
list = require('./factory/list'),
reader = require('./factory/reader'),
op = require('./factory/opener'),
pkg = require(path.join(__dirname, 'package.json'));
program
.version(pkg.version)
.description(pkg.description);
program
.command('top [articleCount]')
.description('List Linda Ikeji Top Stories')
.action(function(articleCount) {
var count = parseInt(articleCount) || 20;
// Prevent negative values
count = count < 0 ? 20 : count;
// Todo: consider using a logger, to enable setting the verbosity of the program
console.log("List top " + count + " Linda Ikeji Stories");
list.top(count);
});
program
.command('read <url>')
.description('Read the story right in your terminal')
.action(function(url){
reader.show(url);
});
program
.command('open <url>')
.description('Opens it in your default browser')
.option('-a, --app <application>', 'specify app to open the url. Eg: firefox')
.action(function(url, options){
var app = options.app || '';
op.open(url, app);
});
program.parse(process.argv);
if (process.argv.length <= 2) {
program.outputHelp();
}