-
Notifications
You must be signed in to change notification settings - Fork 29
/
wunderline-gc.js
executable file
·63 lines (59 loc) · 1.51 KB
/
wunderline-gc.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
63
#!/usr/bin/env node
var app = require("commander");
var async = require("async");
var api = require("./lib/api");
var auth = require("./lib/auth");
app.description("Delete completed tasks").parse(process.argv);
function main() {
async.waterfall([
function (callback) {
api("/lists", function (err, res, body) {
if (err || body.error) {
console.error(JSON.stringify(err || body.error, null, 2));
process.exit(1);
}
callback(err, body);
});
},
function (results, callback) {
var tasks = [];
async.eachLimit(
results,
10,
function (list, done) {
api(
{ url: "/tasks", qs: { completed: true, list_id: list.id } },
function (err, res, body) {
if (err) process.exit(1);
body
.filter(function (task) {
return task.completed === true;
})
.forEach(function (task) {
tasks.push(task);
});
done();
}
);
},
function () {
callback(null, tasks);
}
);
},
function (results, callback) {
async.eachLimit(results, 10, function (task, done) {
api.del(
{ url: "/tasks/" + task.id, qs: { revision: task.revision } },
function (err, res, body) {
if (err) {
//
}
done();
}
);
});
},
]);
}
auth(main);