forked from wayneashleyberry/wunderline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wunderline-inbox.js
executable file
·62 lines (58 loc) · 1.42 KB
/
wunderline-inbox.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
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
var app = require("commander");
var auth = require("./lib/auth");
var async = require("async");
var api = require("./lib/api");
var printList = require("./lib/print-list");
var getInbox = require("./lib/get-inbox");
app.description("View your inbox").parse(process.argv);
function main() {
async.waterfall(
[
function(callback) {
getInbox(function(list) {
callback(null, list);
});
},
function(list, callback) {
async.parallel(
[
function(cb) {
api({ url: "/tasks", qs: { list_id: list.id } }, function(
err,
res,
body
) {
if (err) process.exit(1);
cb(null, body);
});
},
function(cb) {
api({ url: "/subtasks", qs: { list_id: list.id } }, function(
err,
res,
body
) {
if (err) process.exit(1);
cb(null, body);
});
}
],
function(err, results) {
if (err) process.exit(1);
list.tasks = results[0];
list.subtasks = results[1];
callback(null, list);
}
);
}
],
function(err, list) {
if (err) {
process.exit(1);
}
printList(list);
}
);
}
auth(main);