git ssb

0+

dinoworm 🐛 / ssb-reveal



Commit 6a7f12faedfeb0912d99c14588d1deb6db8cecce

better usage

Michael Williams committed on 9/28/2018, 5:49:22 AM
Parent: 6c1d8164c0b4cb9773e04b28181209e711a096fd

Files changed

bin.jschanged mode from 100644 to 100755
bin.jsView
@@ -1,37 +1,47 @@
1 +#!/usr/bin/env node
2 +
13 var pull = require('pull-stream')
24 var Client = require('ssb-client')
35 var sort = require('ssb-sort')
46 var parallel = require('run-parallel')
57
68 var rootMessageId = process.argv[2]
79
8-Client(function (err, client) {
9- if (err) throw err
10 +if (rootMessageId == null) {
11 + console.log('usage: ssb-reveal <rootMessageId>')
12 +} else {
13 + run()
14 +}
1015
11- parallel(
12- [
13- cb => getMessage({ client, messageId: rootMessageId }, cb),
14- cb => getThreadRepliesByRootId({ client, rootMessageId }, cb),
15- cb => client.about.get(cb)
16- ],
17- function (err, [rootMessage, threadReplies, about]) {
18- if (err) throw err
16 +function run () {
17 + Client(function (err, client) {
18 + if (err) throw err
1919
20- var thread = [rootMessage, ...threadReplies]
21- thread.forEach(function (message, index) {
22- if (index === 0) {
23- console.log(`- ${formatMessageLink({ message, about })}`)
24- } else {
25- console.log(` - ${formatMessageLink({ message, about })}`)
26- }
27- })
20 + parallel(
21 + [
22 + cb => getMessage({ client, messageId: rootMessageId }, cb),
23 + cb => getThreadRepliesByRootId({ client, rootMessageId }, cb),
24 + cb => client.about.get(cb)
25 + ],
26 + function (err, [rootMessage, threadReplies, about]) {
27 + if (err) throw err
2828
29- client.close()
30- }
31- )
32-})
29 + var thread = [rootMessage, ...threadReplies]
30 + thread.forEach(function (message, index) {
31 + if (index === 0) {
32 + console.log(`- ${formatMessageLink({ message, about })}`)
33 + } else {
34 + console.log(` - ${formatMessageLink({ message, about })}`)
35 + }
36 + })
3337
38 + client.close()
39 + }
40 + )
41 + })
42 +}
43 +
3444 function formatMessageLink ({ message, about }) {
3545 var authorName = about[message.value.author]['name'][message.value.author][0]
3646 var time = formatTimestamp(message.value.timestamp)
3747 return `[${time} : ${authorName}](${message.key}?unbox=${message.value.unbox})`

Built with git-ssb-web