UNPKG

1.69 kBJavaScriptView Raw
1var pull = require('pull-stream')
2var paramap = require('pull-paramap')
3var u = require('./util')
4var getAbout = require('ssb-avatar')
5var Issues = require('ssb-issues')
6
7exports.help = `
8Usage: git ssb issues [--all|--open|--closed] [<repo>]
9
10 List issues about a repo
11
12Arguments:
13 repo id, url, or git remote name of the repo.
14 default: 'origin' or 'ssb'
15Options:
16 --open Show only open issues (default)
17 --closed Show only closed issues
18 --all Show issues of all state
19`
20
21exports.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}