-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·71 lines (66 loc) · 1.73 KB
/
cli.js
File metadata and controls
executable file
·71 lines (66 loc) · 1.73 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!./node_modules/.bin/babel-node
import Questions from './';
process.on('unhandledRejection', console.error);
const questions = new Questions({
debug: false
});
var cmd = process.argv[2];
switch (cmd) {
case 'search':
questions
.search({
query: process.argv[3] || '*'
})
.pipe(process.stdout)
.on('error', process.exit)
break;
case 'stats':
questions
.stats({
query: process.argv[3] || '*'
})
.then(console.log)
.catch(console.error)
break;
case 'download':
questions
.download()
.catch(console.error);
break;
case 'create-index':
questions
.createIndex()
.catch(console.error)
break;
case 'index':
questions
.index()
.catch(console.error)
break;
case 'reindex':
questions
.deleteIndex()
.then(() => questions.createIndex())
.then(() => questions.indexAll())
.catch(console.error)
break;
case 'redo':
questions
.deleteIndex()
.then(() => questions.createIndex())
.then(() => questions.download())
.then(() => questions.indexAll())
.catch(console.error)
break;
case 'cron':
questions
.download({
cached: true
})
.then(() => questions.indexAll())
.catch(console.error)
break;
default:
console.error('USAGE: hdo-parliament-questions download|create-index|index|reindex|redo|cron|search|stats');
process.exit(1);
}