Files: 403bed97ce3c8f93b87fa33b014b7f20e5e5670d / lib / issues.js
1688 bytesRaw
1 | var pull = require('pull-stream') |
2 | var paramap = require('pull-paramap') |
3 | var u = require('./util') |
4 | var getAbout = require('ssb-avatar') |
5 | var Issues = require('ssb-issues') |
6 | |
7 | exports.help = ` |
8 | Usage: git ssb issues [--all|--open|--closed] [<repo>] |
9 | |
10 | List issues about a repo |
11 | |
12 | Arguments: |
13 | repo id, url, or git remote name of the repo. |
14 | default: 'origin' or 'ssb' |
15 | Options: |
16 | --open Show only open issues (default) |
17 | --closed Show only closed issues |
18 | --all Show issues of all state |
19 | ` |
20 | |
21 | exports.fn = function (argv) { |
22 | if (argv._.length > 1) return u.help('issues') |
23 | |
24 | process.stderr.write('Loading issues...\r') |
25 | var id = u.getRemote(argv._[0]) |
26 | if (!id) throw 'unable to find git-ssb repo' |
27 | |
28 | var open = u.issueStateBool(argv) |
29 | |
30 | u.getSbot(argv, function (err, sbot) { |
31 | if (err) throw err |
32 | sbot.whoami(function (err, feed) { |
33 | if (err) throw err |
34 | var issues = Issues.init(sbot) |
35 | pull( |
36 | issues.list({ |
37 | project: id, |
38 | open: open |
39 | }), |
40 | paramap(function (issue, cb) { |
41 | getAbout(sbot, feed.id, issue.author, function (err, authorAbout) { |
42 | issue.authorName = authorAbout.name |
43 | cb(err, issue) |
44 | }) |
45 | // TODO: show issue petnames? |
46 | }, 8), |
47 | pull.map(function (issue) { |
48 | return issue.id + ' ' + |
49 | '@' + issue.authorName + ' ' + |
50 | (open == null ? issue.open ? 'open: ' : 'closed: ' : '') + |
51 | u.formatTitle(issue.text, 60) |
52 | }), |
53 | pull.drain(function (line) { |
54 | console.log(line) |
55 | }, function (err) { |
56 | if (err) throw err |
57 | process.exit(0) |
58 | }) |
59 | ) |
60 | }) |
61 | }) |
62 | } |
63 |
Built with git-ssb-web